Skip to content

Instantly share code, notes, and snippets.

module AParser (Parser, runParser, satisfy, char, posInt) where
import Control.Applicative
import Data.Char
newtype Parser a = Parser { runParser :: String -> Maybe (a, String) }
satisfy :: (Char -> Bool) -> Parser Char
satisfy p = Parser f
where
-- http://www.seas.upenn.edu/~cis194/hw/10-applicative.pdf
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TupleSections #-}
module AParser where
import Control.Applicative
import Data.Char
-- http://www.seas.upenn.edu/~cis194/hw/06-laziness.pdf
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# OPTIONS_GHC -fno-warn-missing-methods #-}
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)