
1 Jan
2009
1 Jan
'09
3:02 p.m.
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