I started experiment with strict functors. I come to:

> import Control.Exception
> import Foreign
> import Prelude hiding (catch)
> 
> data StrictMonad a = StrictMonad a deriving Show
> 
> instance Functor StrictMonad where
>     f `fmap` StrictMonad v = return $ f v
> 
> instance Applicative StrictMonad where
>     pure = return
>     (<*>) = ap
> 
> instance Monad StrictMonad where
>     return x = unsafePerformIO $ do
>         (return $! x) `catch` \(SomeException _) -> return x
>         return $! StrictMonad x
>     StrictMonad v >>= f = f v

It seems to be valid IMHO Functor and Monad (I haven't prove it) as long
as functions terminates.

Some time ago there was post stating that there is not possible strict
'interesting' functor - I guess that the above is 'interesting' (and due
to halting problem I guess it is not possible to create strict Functor
which would deal with that problem).

Regards

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to