Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pp:2024:l11 [2024/05/20 00:24] tpruteanu [11.4. Probability Distributions (M3 flashbacks)] |
pp:2024:l11 [2025/05/09 20:59] (current) ldaniel fix typo at fmap definition |
||
---|---|---|---|
Line 66: | Line 66: | ||
<code haskell> | <code haskell> | ||
instance Functor Foo where | instance Functor Foo where | ||
- | fmap f fx = px >>= (\x -> return (f x)) | + | fmap f fx = fx >>= (\x -> return (f x)) |
| | ||
instance Applicative Foo where | instance Applicative Foo where | ||
Line 208: | Line 208: | ||
<code haskell> | <code haskell> | ||
- | newtype Prob = Prob [(a, Float)] deriving Show | + | newtype Prob a = Prob [(a, Float)] deriving Show |
</code> | </code> | ||
Line 253: | Line 253: | ||
coin :: Prob Coin | coin :: Prob Coin | ||
- | coin = [(Heads, 0.5), (Tails, 0.5)] | + | coin = Prob [(Heads, 0.5), (Tails, 0.5)] |
unfair_coin :: Prob Coin | unfair_coin :: Prob Coin | ||
- | unfair_coin = [(Heads, 0.6), (Tails, 0.4)] | + | unfair_coin = Prob [(Heads, 0.6), (Tails, 0.4)] |
flip :: Prob [Coin] | flip :: Prob [Coin] |