code logs -> 2007 -> Mon, 15 Oct 2007< code.20071014.log - code.20071016.log >
--- Log opened Mon Oct 15 00:00:52 2007
00:16
<@MyCatVerbs>
Monads are easier in practice than they are in theory.
00:17
<@MyCatVerbs>
"a >>= b" means "make a new action 'a >>= b' by running the output of a through b".
00:36 McMartin [~mcmartin@Nightstar-6094.dsl.pltn13.sbcglobal.net] has joined #code
00:36 mode/#code [+o McMartin] by ChanServ
00:48
<@gnolam>
AnnoDomini: sorry, wasn't paying attention.
00:48
<@gnolam>
Was AFW.
01:06
<@ToxicFrog>
Random number generation in Haskell is made of pain.
01:07 You're now known as TheWatcher[T-2]
01:16
<@McMartin>
I imagine it would be.
01:16
<@McMartin>
The callers would need to keep the internal seed around, I'd guess.
01:16
<@McMartin>
Though maybe there are abstractions to hide that?
01:17 You're now known as TheWatcher[zZzZ]
01:37 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Quit: Z?]
01:40 GeekSoldier|bed [~Rob@Nightstar-4868.pools.arcor-ip.net] has quit [Ping Timeout]
01:45 GeekSoldier|bed [~Rob@Nightstar-4868.pools.arcor-ip.net] has joined #code
01:53 GeekSoldier|bed [~Rob@Nightstar-4868.pools.arcor-ip.net] has quit [Ping Timeout]
01:53 Vornicus is now known as Darius
02:31
<@ToxicFrog>
It's made of monads.
02:31
<@ToxicFrog>
I can't figure out monads.
02:31
<@ToxicFrog>
And it seems that as soon as they've involved, the type-inference engine develops a hunger for human flesh.
02:32
<@McMartin>
Damn
02:32
<@McMartin>
I was hoping you'd explain monads to me.
02:32
<@McMartin>
Because I only know of them as the construct in Abstract Algebra.
03:25 Doctor_Nick [~nick@Nightstar-23600.hsd1.fl.comcast.net] has joined #code
03:25
< Doctor_Nick>
ugh
03:26
< Doctor_Nick>
ok, i have another question about piping
03:26
< Doctor_Nick>
pastebin.com/m5ddeed1a
03:28
< Doctor_Nick>
after i fork, the child process writes to the pipe, and the parent process waits for the child, then forks again. the child of that reads from the pipe, and the parent waits for the child, then returns.
03:29
< Doctor_Nick>
the problem is, it seems that there's no EOF being written to the pipe
03:29
< Doctor_Nick>
so the 2nd child process just hangs
03:36
<@ToxicFrog>
Is the pipe actually getting close()ed?
03:36
<@ToxicFrog>
You won't get EOF until that happens.
03:38
< Doctor_Nick>
ToxicFrog: I dunno, the child is supposed to do that when it exits, and i'm doing close(fd[1]) in the 2nd child besides
03:40
< Doctor_Nick>
ohhh
03:40
< Doctor_Nick>
i have to close(fd[1]) before i fork again
03:40
< Doctor_Nick>
duh
04:29 GeekSoldier|bed [~Rob@Nightstar-3679.pools.arcor-ip.net] has joined #code
04:44 Forj [~Forj@Nightstar-2310.ue.woosh.co.nz] has joined #code
04:45 mode/#code [+o Forj] by ChanServ
04:46 Forj [~Forj@Nightstar-2310.ue.woosh.co.nz] has quit [Quit: Gone]
04:55
<@ToxicFrog>
McMartin: I think I have some understanding of monads now.
05:15 Forj [~Forj@203.211.124.ns-3224] has joined #code
05:15 mode/#code [+o Forj] by ChanServ
06:39 Darius is now known as Vornicus
06:43 GeekSoldier|bed is now known as GeekSoldier|work
06:50 GeekSoldier|work [~Rob@Nightstar-3679.pools.arcor-ip.net] has quit [Ping Timeout]
07:16 Chalcedon is now known as Forjadon
08:03 Forjadon is now known as Chalcedon
09:24 Vornicus is now known as Vornicus-Latens
09:47 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has joined #Code
09:47 mode/#code [+o gnolam] by ChanServ
09:51 You're now known as TheWatcher
09:51 Chalcedon [~Chalcedon@Nightstar-2310.ue.woosh.co.nz] has quit [Quit: Gone]
10:12 Forj [~Forj@203.211.124.ns-3224] has quit [Quit: Gone]
10:15 GeekSoldier|work [~Rob@Nightstar-5414.pools.arcor-ip.net] has joined #code
10:34 GeekSoldier|work [~Rob@Nightstar-5414.pools.arcor-ip.net] has quit [Ping Timeout]
10:38 GeekSoldier|work [~Rob@Nightstar-4473.pools.arcor-ip.net] has joined #code
11:16 MyCatSchemes [~rb6822@Nightstar-23953.cs.bris.ac.uk] has joined #code
11:49 ReivOut is now known as Reiver
12:02 MyCatSchemes [~rb6822@Nightstar-23953.cs.bris.ac.uk] has quit [Client exited]
12:48 Reiver is now known as ReivZzz
12:53 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has quit [Ping Timeout]
12:54 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has joined #code
12:54 mode/#code [+o Pi] by ChanServ
13:03 Thaqui [~Thaqui@Nightstar-26433.jetstream.xtra.co.nz] has quit [Quit: This computer has gone to sleep]
13:09 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has quit [Ping Timeout]
13:11 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has joined #code
13:11 mode/#code [+o Pi] by ChanServ
13:14 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has quit [Ping Timeout]
13:23 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has joined #code
13:23 mode/#code [+o Pi] by ChanServ
13:26 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has quit [Ping Timeout]
13:29 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has joined #code
13:29 mode/#code [+o Pi] by ChanServ
13:32 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has quit [Ping Timeout]
13:34 Pi [~sysop@Nightstar-24414.hsd1.wa.comcast.net] has joined #code
13:34 mode/#code [+o Pi] by ChanServ
14:23 MyCatSchemes [~rb6822@Nightstar-23444.cs.bris.ac.uk] has joined #code
15:13 GeekSoldier|work is now known as GeekSoldier
15:40 MyCatSchemes [~rb6822@Nightstar-23444.cs.bris.ac.uk] has quit [Quit: Swim, swim, hungry!]
15:50
< Mischief]>
Sit down, children, I have a tale on how things became as they are!
15:50
< Mischief]>
In the beginning, the database was void and without form...
15:50
< Mischief]>
So One spake, "Let there be LIGHT!"
15:50
< Mischief]>
And then there was a compiler error.
15:50
< Mischief]>
Word not define: Light
17:13 MyCatSchemes [~rb6822@Nightstar-23399.cs.bris.ac.uk] has joined #code
17:29 Syloqs-AFH [Syloq@NetAdmin.Nightstar.Net] has quit [Connection reset by peer]
18:14 AnnoDomini [AnnoDomini@Nightstar-29095.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
18:18 AnnoDomini [AnnoDomini@Nightstar-28848.neoplus.adsl.tpnet.pl] has joined #Code
18:18 mode/#code [+o AnnoDomini] by ChanServ
19:09 * McMartin speaks: CREATE DATABASE light;
19:13
< Doctor_Nick>
i see what you did there
19:14
< GeekSoldier>
hey, Robert`); DROP TABLE Students;--
19:15
<@McMartin>
IIRC, his name was Robert'); DROP TABLE Students;-- but that might be a dialect issue.
19:17
< Doctor_Nick>
i hated that comic
19:17
< GeekSoldier>
nah, it was bad memory, and a long time since I've done any sql work.
19:18
<@McMartin>
As it stands, that trick doesn't work on JDBC/MySQL, because the MySQL driver refuses to take more than one statement at a time.
19:22
<@McMartin>
The ' OR '1' = '1 one still works, though.
19:24 MyCatSchemes [~rb6822@Nightstar-23399.cs.bris.ac.uk] has quit [Quit: Swim, swim, hungry!]
19:24
<@ToxicFrog>
Doctor_Nick: why?
19:25
<@McMartin>
Hah. Look at me, still talking when there's science to do
19:25 * McMartin heads off to lab again.
19:26
<@ToxicFrog>
SCIENCE!
19:27
< Doctor_Nick>
the setup was stupid and the punchline was obvious
19:28 Vornicus-Latens is now known as Vornicus
19:29
<@McMartin>
The joke, you realize, was not "did you really name your kid that" but "Oh yes! Little Bobby Tables, we called him."
19:41 Chalcedon [~Chalcedon@Nightstar-2310.ue.woosh.co.nz] has joined #code
19:41 mode/#code [+o Chalcedon] by ChanServ
19:49 GeekSoldier is now known as GeekSoldier|bed
20:10 Chalcy [~Chalcedon@Nightstar-2310.ue.woosh.co.nz] has joined #code
20:10 mode/#code [+o Chalcy] by ChanServ
20:10 Chalcedon [~Chalcedon@Nightstar-2310.ue.woosh.co.nz] has quit [Killed (NickServ (GHOST command used by Chalcy))]
20:10 Chalcy is now known as Chalcedon
20:15 Netsplit DeepThought.NY.US.Nightstar.Net <-> Blargh.CA.US.Nightstar.Net quits: @gnolam
20:16 Netsplit over, joins: gnolam
20:16 mode/#code [+o gnolam] by ChanServ
21:21
<@McMartin>
Hey, TF: What tutorial were you using to learn Haskell?
21:28
<@ToxicFrog>
All of them ;.;
21:35
<@McMartin>
Heh.
21:35
<@McMartin>
Any suggestions on a place to start?
21:35 GeekSoldier|bed [~Rob@Nightstar-4473.pools.arcor-ip.net] has quit [Ping Timeout]
21:36
<@AnnoDomini>
o/` Okay, is time for end, no more will I sang. Let me take you back in time, I want for you to experience Big Bang! o/`
21:37
<@ToxicFrog>
McMartin: the Gentle Introduction to Haskell, while not particularly gentle, will get you going pretty fast. Beyond that, hit the meta-tutorial on the wiki and follow anything that looks interesting.
21:37
<@McMartin>
Nod
21:37
<@McMartin>
Also, ghc or hugs?
21:38
<@ToxicFrog>
I've been using ghc/ghci, from what I've seen there's not much to choose between them.
21:39
<@ToxicFrog>
I've also arrived at the conclusion that Haskell is Not The Right Language for this project ;.;
21:39 Chalcedon is now known as ChalcyNap
21:39
<@McMartin>
Heh
21:39 * McMartin suggests poking at OCaml, then~
21:39
<@McMartin>
Ignore the "O" bits, though.
21:40
<@McMartin>
OCaml's OO extensions are made of hate and woe
21:40
<@ToxicFrog>
How painful is random number generation in OCaml?
21:40
<@ToxicFrog>
Because the problem I kept running into is that these algorithms are heavily dependent on randomness.
21:40
<@ToxicFrog>
Which is stateful.
21:40
<@McMartin>
ML is stateful, so even if it doesn't have its own, it's easy.
21:40
<@McMartin>
Let me check its libraries.
21:41
<@McMartin>
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Random.html
21:41
<@ToxicFrog>
Which means using the State monad, which is fairly cool, but not pretty no matter how you slice it.
21:42
<@McMartin>
Yeah, so, ML just lets you talk about memory cells.
21:42
<@McMartin>
Or declare record fields mutable.
21:44
<@ToxicFrog>
Hmm.
21:45
<@ToxicFrog>
Something for the next project, then
21:45
<@ToxicFrog>
But I'm at the point where I fall back on Lua, because I have less than a week to finish this in.
21:46
<@McMartin>
Righto
21:46 * McMartin shall thus begin learning Haskell.
21:46
< Doctor_Nick>
and that was the last we saw of mcmartin
21:46
< Doctor_Nick>
the end
21:47
<@ToxicFrog>
Haskell is really cool as long as you don't need state. Infinite data structures, yum.
21:47
<@McMartin>
Fools! I'll destroy you all.
21:47
<@McMartin>
Also, functional is my "native dialect", and I have an accent in other paradigms.
21:48
<@McMartin>
Lots of function pointers in C, heavy use of the Strategy and Visitor patterns in OO.
21:48 * ToxicFrog nods
21:49
<@ToxicFrog>
I've found myself doing the same thing since learning Lua, but I still likes my mutable state.
21:50
<@ToxicFrog>
Oh. Haskell's type system is the other really cool bit.
21:50
<@ToxicFrog>
Where the pain actually began was where I tried to combine my custom types with stateful operations.
21:50
<@McMartin>
Yeah, by "functional" here I don't mean "stateless", I mean "exploiting higher-order functions"
21:51
<@ToxicFrog>
Aah.
21:51
<@ToxicFrog>
Functional as opposed to functionally pure, I guess.
21:52
<@McMartin>
Yeah
21:52
<@McMartin>
Besides, LISP isn't pure either =P
21:52
<@McMartin>
And that was what I learned on
21:53
<@ToxicFrog>
Heh.
21:53 * McMartin is also finally getting around to implementing something in 6502 assembly using functional/OO gimmickry
21:53
<@McMartin>
It's hard to tell them apart once you hit the machine language level
21:54
<@ToxicFrog>
A lot of things ar4.
21:54 * ToxicFrog ponders GA.Solution
21:54
<@ToxicFrog>
I'm going to need gray codes for this.
21:54
<@ToxicFrog>
;.;
21:58 * Vornicus had, somewhere, algorithms for switching between regular numbers and gray codes.
22:00
<@jerith>
Generating gray codes is easy, though.
22:00
< Vornicus>
it's not hard at all, really. Well, one direction is a pain, but the other one is not.
22:00
<@ToxicFrog>
I need to do both directions.
22:01
<@ToxicFrog>
...actually, wait, no.
22:01
<@ToxicFrog>
I only need to do code->actual
22:02
< Vornicus>
...erf. they're mutating cascade algorithms.
22:04
<@ToxicFrog>
Mmm, first-class types which are also generator functions.
22:05 mode/#code [+o Vornicus] by Vornicus
22:05
<@Vornicus>
http://community.livejournal.com/cs_lectures/4495.html?mode=reply
22:09 ChalcyNap is now known as Chalcedon
22:09
<@ToxicFrog>
Tahnkye
22:36
<@ToxicFrog>
Feels weird to be putting () around function arguments.
22:37
<@ToxicFrog>
Hell, feels weird to have functions that aren't curry.
22:42
<@McMartin>
Delicious curry!
22:43
<@ToxicFrog>
Yes!
22:43
<@ToxicFrog>
I am now finding the lack of first-class operators and effortless partial application in Lua cramped.
23:15
<@McMartin>
"Haskell's I/O system is built around a somewhat daunting mathematical foundation: the monad. However, understanding of the underlying monad theory is not necessary to program using the I/O system. Rather, monads are a conceptual structure into which I/O happens to fit. It is no more necessary to understand monad theory to perform Haskell I/O than it is to understand group theory to do simple arithmetic."
23:15
<@McMartin>
But but but. I do understand group theory.
23:26
<@McMartin>
Hmm. I'm not seeing the difference between >>= and "let x = y in".
23:35
<@ToxicFrog>
AIUI, foo >>= bar is roughly "let x = demonadify foo in bar x"
23:36
<@ToxicFrog>
That is to say, it pulls out the non-monad part of foo, then runs bar on it
23:37
<@McMartin>
Right, but, what I mean is, you're computing a set of values in sequence, each of which knows about the stuff that happened before
23:37
<@ToxicFrog>
Yes
23:37
<@McMartin>
So, like, instead of, in C, "a = 3; b = a+2; c = a * b;", you would have, in ML:
23:38
<@McMartin>
"let a = 3 in let b = a + 2 in a * b;"
23:38
<@ToxicFrog>
Basically, except that >>= also gets monadic stuff involved.
23:38
<@McMartin>
And, if I read the Haskell stuff right, in Haskell with monads that's "do a <- 3; b <- a+2; return a * b"
23:38
<@McMartin>
But the semicolons are linebreaks and indents.
23:39 ReivZzz is now known as ReivOut
23:45
<@ToxicFrog>
You can in fact use do { foo; bar; } instead if so inclined.
23:45
<@ToxicFrog>
And yes, it is.
23:46
<@McMartin>
Yeah, I think I'll be able to handle monadic programming without too much difficulty.
23:46
<@McMartin>
But!
23:46
<@McMartin>
C64 OO hax first.
23:48
<@ToxicFrog>
Heh.
23:48
<@ToxicFrog>
I would appreciate your insights WRT: the State monad, once you've had a chance to play with it some.
23:48
<@ToxicFrog>
...the lack of list comprehensions is also making me sad.
23:49
<@ToxicFrog>
I need to break out metalua and start implementing these things.
23:49
<@McMartin>
Understood
23:50
< Mischief]>
The TECHNOLOGICAL SINGULARITY!
23:50 * Mischief] slaps self for being random.
23:50
<@McMartin>
My problem with the state monad is that my LISP/ML background means I'm used to hauling state around manually.
23:50
<@ToxicFrog>
Aah.
23:50
<@McMartin>
So I'd be very unlikely to ever want to *use* the State monad.
23:50
<@ToxicFrog>
I find hauling state around manually to be deeply unpleasant.
23:51 * McMartin tends to use that in OO to violate encapsulation when necessary.
23:51
<@McMartin>
There are exceptions: See also the BinStruct module I made for OCaml.
23:51
<@ToxicFrog>
If I were going to do it, though, I'd probably do it by making a StdGen (random number generator) part of the Chromosome and Population types.
23:51
<@McMartin>
Mmm, yes, a PRNG would be a good use of a State monad
23:51
<@McMartin>
Though I'd probably just make a Random monad.
23:52
<@ToxicFrog>
Thus, if you need to mutate, you ask the generator for a list of numbers, and the mutated object you return includes a new generator grown from the old one.
23:52
<@McMartin>
Yeah
23:52
<@McMartin>
I suspect I'd want my PRNG to in fact be an infinite list~
23:52
<@ToxicFrog>
Well, that's trivial.
23:52
<@ToxicFrog>
And that's what I actually did, at the top level.
23:53
<@ToxicFrog>
The problem is that you need to remember where in the list you are, because it's a list, not a stream.
23:53
<@McMartin>
Yeah. Infinite list + monadic index, I suspect.
23:53
<@McMartin>
Or rather, forever replacing itself with its own tail.
23:53
<@ToxicFrog>
Yeah. Which is what I was using State to do, before the brainfoam occurred.
23:54
<@McMartin>
Is State even standard?
23:54
<@ToxicFrog>
Yes.
23:54
<@McMartin>
(My *first* Haskell program will be to reduce arithmetic ASTs to RPN notation, I think.)
23:54
<@ToxicFrog>
It's Control.Monad.State, IIRC
23:54
<@ToxicFrog>
I was using that and System.Random
23:55
<@ToxicFrog>
Anyways, what I basically had was a get_more_randoms :: Int -> [Double], which asks the monad for the list, grabs the first n elements, stuffs what's left back into the state and returns what it headed.
23:55
<@ToxicFrog>
Except that, since it's monadic, it actually has signature Int -> State [Double] [Double]
23:56
<@McMartin>
Right.
23:56 * McMartin will fiddle with it Later (tm).
23:56
<@ToxicFrog>
Which poisons the rest of the call chain, and leads to suffering and woe.
23:56
<@McMartin>
Right
23:57
<@McMartin>
I'm not convinced, given that monadic programming has to happen at the highest levels, that you can get away with this at all without being monadic all the way to the top
23:58
<@McMartin>
Unless you can have the monadic part be only at the top and be functional at all levels below it.
23:59
<@ToxicFrog>
While theoretically possible, this makes my signatures much uglier, as I have to pass entropy sources all the way down and back up.
23:59
<@ToxicFrog>
And in theory I have problem being monadic all the way to the top.
23:59
<@ToxicFrog>
It's actually doing so that hurts.
--- Log closed Tue Oct 16 00:00:29 2007
code logs -> 2007 -> Mon, 15 Oct 2007< code.20071014.log - code.20071016.log >