On Tue 25 Jan, Anton Moscal wrote:
> Q: Exist simple translation of the any monadic program into "unique types
> style" or not? And the inverse: translation of the program with unique
> types into monadic style?
I would guess the answer is yes, provided all world transforming functions
are of type IO a = World -> (a, World). So you would need to convert
Clean functions of type (World -> World) to something like..
IO () = World -> ((), World)
(I can't recall offhand if Clean has a Void type, if not you could use
an Int or Bool instead I suppose). Something like this perhaps..
IOconvert :: (World -> World) -> IO ()
IOconvert f world = ((),f world)
(>>) :: IO a -> IO b -> IO b
(>>) f g world = let (_,new_world) = f world
in g new_world
(>>=) :: IO a -> (a -> IO b) -> IO b
(>>=) f g world = let (a,new_world) = f world
in g a new_world
return :: x -> IO x
return x world = (x,world)
Regards
--
Adrian Hey