bnfc

Utils

Contents

Synopsis

Documentation

type Parser a b = [a] -> [(b, [a])]

(...) :: Parser a b -> Parser a c -> Parser a (b, c)

(|||) :: Parser a b -> Parser a b -> Parser a b

lit :: Eq a => a -> Parser a a

(***) :: Parser a b -> (b -> c) -> Parser a c

succeed :: b -> Parser a b

fails :: Parser a b

parseResults :: Parser a b -> [a] -> [b]

List utilities

replace

Arguments

:: Eq a 
=> a

Value to replace

-> a

Value to replace it with

-> [a] 
-> [a] 

Replace all occurences of a value by another value

split :: Eq a => a -> [a] -> ([a], [a])

Split a list on the first occurence of a value. Does not include the value that was split on in either of the returned lists.

splitAll :: Eq a => a -> [a] -> [[a]]

Split a list on every occurence of a value. If the value does not occur in the list, the result is the singleton list containing the input list. Thus the returned list is never the empty list.

File utilities

prepareDir :: FilePath -> IO ()

Ensure that a directory exists.

createDirectoryIfNotExists :: FilePath -> IO ()

Ensure that a directory exists. All parent directories must already exist.

basename :: String -> String

Like basename(1), remove all leading directories from a path name.