Skip to content

Instantly share code, notes, and snippets.

module Parser where
newtype Parser a = P { parse :: String -> [(a, String)] }
instance Functor Parser where
fmap g p = P (\inp -> case parse p inp of
[] -> []
[(v, out)] -> [(g v, out)])
instance Applicative Parser where
module Parser where
newtype Parser a = P { parse :: String -> [(a, String)] }
instance Functor Parser where
fmap g p = P (\inp -> case parse p inp of
[] -> []
[(v, out)] -> [(g v, out)])
instance Applicative Parser where