This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://www.seas.upenn.edu/~cis194/hw/10-applicative.pdf | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE TupleSections #-} | |
module AParser where | |
import Control.Applicative | |
import Data.Char |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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) |
NewerOlder