
6 Feb
2017
6 Feb
'17
7:40 p.m.
Hi, I have a State by another name, Stat, just to experiment and learn. newtype Stat s a = Stat { runStat :: s -> (a, s) } instance Functor (Stat s) where fmap f (Stat g) = Stat $ \s -> (f a, s) where (a, s) = g s instance Applicative (Stat s) where pure a = Stat $ \s -> (a, s) (Stat f) <*> (Stat g) = Stat $ \s -> (a, s) where (a, s) = undefined I really can’t get what the <*> in the Applicative should be! I just do see how I ‘get the f out of the Stat’ and then apply it. I’d be really grateful if someone would explain what it should be and the steps/reasoning needed to get there. Many thanks Mike