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 options:

1) Implement yours as a restricted version of Control.Monad.State

   type ReaderAC = State
   readAC = get >>= \x -> put (tail x) >> return (head x)

I'll at least have a look at that...

2) or (as Isaac demonstrated) look to the definition of
Control.Monad.State.State for guidance own how to structure your
monad.

Ah yes. I just sat down to do this, and... oh look. There in the first few lines, a non-standard language extension that I don't understand.

...which neatly brings us back to the reason I'm trying to reimplement this by hand in the first place. ;-)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to