Nicolas Frisby wrote:
Your intended behavior for Reader indicates stateful computational
features. The "read later" roughly expands to "be read by some monadic
action on the rhs of a >>=" as in
(read >>= \x -> read {-this is later-} >>= ...)
Recognizing the stateful nature gives you two option
On Sun, 27 May 2007, Andrew Coppin wrote:
> such that a Reader is created with an initial list, and the read
> function fetches 1 element out of that list. That is, the expression "x
> <- read" will take the head element of the list and put it into x,
> keeping the tail to be read later.
>
> (Oh
On 5/27/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:
[snip]
such that a Reader is created with an initial list, and the read
function fetches 1 element out of that list. That is, the expression "x
<- read" will take the head element of the list and put it into x,
keeping the tail to be read late
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Andrew Coppin wrote:
> Take a look at the following:
>
> data Writer o v = Writer [o] v
>
> instance Monad (Writer o) where
>return v = Writer [] v
>
>(Writer os v) >>= f =
> let (Writer os' v') = f v
> in Writer (os ++ os') v'
>
On Sun, May 27, 2007 at 02:43:32PM +0100, Andrew Coppin wrote:
> Any thoughs?
Take a look at MonadSupply on the wiki:
http://haskell.org/haskellwiki/New_monads/MonadSupply
Stefan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell
Take a look at the following:
data Writer o v = Writer [o] v
instance Monad (Writer o) where
return v = Writer [] v
(Writer os v) >>= f =
let (Writer os' v') = f v
in Writer (os ++ os') v'
write :: o -> Writer o ()
write o = Writer [o] ()
writes :: [o] -> Writer o ()
wri