[Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell

Miguel Mitrofanov miguelimo38 at yandex.ru
Tue May 19 03:54:50 EDT 2009


I've posted it once or twice.

newtype C m r a = C ((a -> m r) -> m r)

It's a monad, regardless of whether m is one or not. If you have something like "return" and "bind", but not exactly the same, you can make 
"casting" functions

m a -> C m r a

and backwards.

Jason Dusek wrote on 19.05.2009 10:23:
> 2009/05/18 Miguel Mitrofanov <miguelimo38 at yandex.ru>:
>> On 19 May 2009, at 09:06, Ryan Ingram wrote:
>>
>>> This is a common problem with trying to use do-notation; there are
>>> some cases where you can't make the object an instance of Monad.  The
>>> same problem holds for Data.Set; you'd can write
>>>
>>> setBind :: Ord b => Set a -> (a -> Set b) -> Set b
>>> setBind m f = unions (map f $ toList m)
>>>
>>> but there is no way to use setBind for a definition of >>=
>> You can use a continuation trick.
> 
>   Trick?
> 
> --
> Jason Dusek
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 


More information about the Haskell-Cafe mailing list