Re: Monadic Call/CC?

2002-02-23 Thread Marcin 'Qrczak' Kowalczyk
Thu, 21 Feb 2002 19:36:13 -0800, Ashley Yakeley [EMAIL PROTECTED] pisze: data ContMonad p a = MkContMonad ((a - p) - p); [...] It's in GHC in module MonadCont, together with a monad transformer providing continuations and some instances. -- __( Marcin Kowalczyk * [EMAIL PROTECTED]

Re: Monadic Call/CC?

2002-02-23 Thread Ashley Yakeley
At 2002-02-23 07:55, Marcin 'Qrczak' Kowalczyk wrote: It's in GHC in module MonadCont, together with a monad transformer providing continuations and some instances. Could this sort of thing _please_ be added to http://www.haskell.org/ghc/docs/latest/set/book-hslibs.html or somewhere? Is this

Re: Monadic Call/CC?

2002-02-22 Thread Richard Uhtenwoldt
Ashley Yakeley writes: Now here's the interesting thing. The usual way to represent real-world functions (i.e. with side-effects, or changing the world) from a to b is to define a special _type constructor_, 'IO', and define the function as 'a - IO b'. But an alternative, would have been to

Re: Monadic Call/CC?

2002-02-22 Thread Ashley Yakeley
At 2002-02-22 01:36, Richard Uhtenwoldt wrote: Yeah, it's called continuation-passing style (CPS). Good. I have a small collection of wheels I've reinvented in my ignorance. So, congratulations, you've written call/cc in Haskell. I think. So, what I said this afternoon, namely, that call/cc is

Re: Monadic Call/CC?

2002-02-22 Thread Ashley Yakeley
At 2002-02-22 01:36, Richard Uhtenwoldt wrote: So, congratulations, you've written call/cc in Haskell. I think. Yes. test2 :: CPS (IO ()) (); test2 = do { liftM (putStr aa\n); ref - liftM (newIORef Nothing); liftM (putStr bb\n); flag - peirceM

Re: Monadic Call/CC?

2002-02-21 Thread Ashley Yakeley
At 2002-02-20 22:15, I wrote (on the Haskell list): Haskell? Given this: class (Monad m) = PeirceMonad m where { peirceM :: ((a - m b) - m a) - m a; }; ...which Monads can be made PeirceMonads? This is untested, but... instance PeirceMonad

Re: Monadic Call/CC?

2002-02-21 Thread Richard Uhtenwoldt
Ashley Yakeley writes: instance PeirceMonad IO where { peirceM foo = do { ref - newIORef Nothing; catch (foo (\a - do { writeIORef ref (Just a); ioError (userError break); }))

Re: Monadic Call/CC?

2002-02-21 Thread Ashley Yakeley
Given this: class (Monad m) = PeirceMonad m where { peirceM :: ((a - m b) - m a) - m a; }; ...which Monads can be made PeirceMonads? Here's one: data ContMonad p a = MkContMonad ((a - p) - p); unContMonad (MkContMonad app) = app;

Re: Monadic Call/CC?

2002-02-21 Thread Ashley Yakeley
At 2002-02-21 19:36, I wrote: And then your 'main' function has type 'Action'. Sorry, And then your 'main' function has type 'Action - Action'. -- Ashley Yakeley, Seattle WA ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Monadic Call/CC?

2002-02-20 Thread Ashley Yakeley
Has anyone investigated monadic call-with-current-continuation in Haskell? Given this: class (Monad m) = PeirceMonad m where { peirceM :: ((a - m b) - m a) - m a; }; ...which Monads can be made PeirceMonads? The corresponding non-monadic