[Haskell-cafe] Stupid question #852: Strict monad
Stephan Friedrichs
deduktionstheorem at web.de
Thu Jan 1 15:02:38 EST 2009
Hello Brian,
Brian Hurt wrote:
>
> [...]
>
> So today's question is: why isn't there a Strict monad? Something like:
>
> data Strict a = X a
>
> instance Monad Strict where
> ( >>= ) (X m) f = let x = f m in x `seq` (X x)
> return a = a `seq` (X a)
unless I am mistaken, this violates the first monad law (see Prelude
documentation)
return a >>= k == k a
for k = const (return 3) and a = undefined, because
return undefined >>= _ === _|_
but
const (return 3) undefined === return 3
Generally speaking, the first monad law only holds for strict functions
in your monad.
>
> [...]
>
Happy new year,
Stephan
--
Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.
- Dieter Nuhr
More information about the Haskell-Cafe
mailing list