fmap f p = Parser ((.) (fmapEither (fmap1st f)) (runParser p)); pure x = Parser (\s -> Right (x, s)); apply pf px = Parser (\s -> bindEither (runParser pf s) (\res1 -> case res1 of { (f, s') -> bindEither (runParser px s') (\res2 -> case res2 of { (x, s'') -> Right (f x, s'') })})); fmapEither f e = case e of { Left x -> Left x; Right x -> Right (f x) }; bindEither m f = case m of { Left x -> Left x; Right x -> f x }; fmap1st f p = case p of { (l, r) -> (f l, r) }; runParser p = case p of { Parser g -> g }; (.) f g x = f (g x); id x = x; fl1_a = fmap id (Parser g); fl1_b = Parser g; fl2_a = fmap ((.) f g) (Parser g); fl2_b = ((.) (fmap f) (fmap g)) (Parser g); al1_a = apply (pure id) v; al1_b = v;