http://sassa-nf.livejournal.com/ ([identity profile] sassa-nf.livejournal.com) wrote in [personal profile] deniok 2016-11-06 01:49 pm (UTC)

instance Applicative Parser where
  pure a = Parser $ \s -> [(a, s)]
  (Parser ps) <*> (Parser qs) = Parser $ \s -> [ (f a, t)
                                               | (f, s') <- ps s
                                               , (a,t) <- qs s'
                                               ]

instance Alternative Parser where
  empty = Parser $ const []
  (Parser ps) <|> (Parser qs) = Parser $ (++) <$> ps <*> qs

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting