On Sat, 2011-03-05 at 00:51 +0100, Yves Parès wrote: > > > But I don't have an explicit type to put. > I cound do: > > data CtxFooInst > instance CtxFoo CtxFooInst > > and declare runFoo as this: > > runFoo :: MyIO CtxFooInst a -> IO a > > But I loose the ability to make functions that can run several > contexts. >
He meant: newtype MyIO c a = MyIO (IO a) data CtxFooInst instance CtxFoo CtxFooInst runMyIO :: CtxFoo c => MyIO c a -> IO a runMyIO (MyIO x) = x someAction :: CtxFoo c => MyIO c () someAction = MyIO (PutStrLn "Foo") main = runMyIO (someAction :: MyIO CtxFooInst ()) In such way you push the abstraction down to main but actions are contex-independent. Regards _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe