[Haskell-cafe] Replacing [a] with (Set c a) in Monad instance.
Daniel McAllansmith
dm.maillists at gmail.com
Tue Jan 30 18:01:39 EST 2007
Hello.
Given:
newtype Dist a = D {unD :: [(a,Int)]}
instance Monad Dist where
return x = D [(x,1)]
d >>= f = D [(y,q*p) | (x,p) <- unD d, (y,q) <- unD (f x)]
fail _ = D []
How would one change Dist to wrap an instance of the (Data.Edison.Set c a)
typeclass so that the Monad instance could be implemented in terms of e.g.
singleton, unionWith, empty, etc?
Thanks
Daniel
More information about the Haskell-Cafe
mailing list