Move the function 'first' from Parser to MyPrelude

It is useful and generic.
This commit is contained in:
hasufell 2014-10-12 01:57:20 +02:00
parent 60f59bb2b7
commit 24810e5970
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 6 additions and 4 deletions

View File

@ -40,3 +40,8 @@ tailInit :: [a] -> [a]
tailInit xs
| length xs > 2 = tail . init $ xs
| otherwise = []
-- |Apply a function to the first element of a tuple.
first :: (a -> b) -> (a,c) -> (b,c)
first f (x,y) = (f x, y)

View File

@ -14,6 +14,7 @@ module Parser.Core (Parser,
import Control.Applicative
import Data.Char
import MyPrelude
-- |The parser type. It allows us to create specific parsers,
@ -49,10 +50,6 @@ inParser :: ((String -> Maybe (a1, String))
inParser f p = MkParser . f . runParser $ p
first :: (a -> b) -> (a,c) -> (b,c)
first f (x,y) = (f x, y)
-- |Creates a Parser that parses a Char depending on a given condition.
satisfy :: (Char -> Bool) -- ^ condition
-> Parser Char -- ^ created Parser