#haskell - Fri 16 Mar 2007 between 01:14 and 01:27

NY Lost Funds



glguyi guess you haven't gotten that far before the error hit?
sciolizerglguy: I don't. If I wanted it to calculate, I would do main = print $ run fib $ 5
glguynot "constA 5 >>> fib"?
sciolizer@hoogle constA
lambdabotNo matches found
sciolizerglguy: What is constA?
nmessengerI don't really understand the code, but wouldn't fib's count be _|_ since it calls itself recursively?
glguythat could be HXT specific...
HXT is the only time I use arrows
sciolizerglguy: oh, ok
glguyI don't understand what the "run" field is for
sciolizerglguy: run "unlifts" the Arrow.
nmessengerglguy: it's the "unpacker" the way the "runState" unpacks a State monad's underlying function.
sciolizernmessenger: count should return the number of explicit/implicit >>>'s.
glguysure, but then how does that affect the count
ah
but you don't know that
because you haven't done the recursion
nmessengersciolizer: right, and since fib has some (>>>)'s, and is also defined in terms of itself, count should be infinite.
glguysciolizer: constA x is an arrow that ignores its input and returns x
nmessengerI'm not sure how to do a "running total of (>>>)'s so far", but it would require an input
sciolizerglguy: ok
sjanssenfantasma: no, both dons and I have darcs.haskell.org accounts, the permissions are set such that anyone in the "darcs" group can write to the repo
nmessengersciolizer: try "let x = x >>> x in count arr x :: AppCounter", should also blow the stack.
sciolizernmessenger: maybe I just don't understand this yet. My thinking is that since the count field and the run field are independent, then Haskell's lazy evaluation will prevent any function composition (and therefore recursion) from ever happening.
nmessengerer, AppCounter () ()
sjanssensciolizer: you can do some dynamic programming with monads
nmessengersciolizer: but you're trying to print an Int, so Haskell has to evaluate that Int, which causes the stack explosion.
sciolizersjanssen: any examples?
nmessengersciolizer: try that example in the REPL
sciolizernmessenger: uh, type error
actionnmessenger tries
nmessengertries
sjanssensciolizer: I don't have any canned examples. The idea is to use a state monad that carries around a Map of function results
sciolizersjanssen: ok. I thought of that before (a few months ago), but ran into a wall somewhere. Maybe I just need to visit it again.
nmessengergrr, after fixes, it was 1
sciolizernmessenger: Yeah, because x >>> x has 1 ">>>".
nmessengerhere we go: "let x = x >>> x :: AppCounter () () in count x" blows the stack
sciolizer: actually, it's because arr starts at 1 and (arr x) has no (>>>)'s, so it doesn't increase.
sciolizernmessenger: You're right. But I still don't understand why.
nmessenger> let x = x + x :: Int in x

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 93 100 107 

IrcArchive

NY Lost Funds