[Haskell-cafe] Problem with own written monad

Jules Bean jules at jellybean.co.uk
Tue Jan 8 05:32:03 EST 2008


Michael Roth wrote:
> Did you mean:
> 
> 	isolate :: Stack s1 a -> Stack s2 a
> 	isolate stack = Stack f where f xs = ( fst $ run stack [], xs)

Yes. What's slightly interesting is the way the types promise the 
isolation: the Stack s1 action clearly can't be consuming any of the 
[s2] stack, because that is the wrong type. This continues to hold even 
if you happen to run it with s1 == s2.

Jules


More information about the Haskell-Cafe mailing list