Safe HaskellSafe

Data.Algorithm.SatSolver.Utils

Contents

Synopsis

List

safeHead :: [a] -> Maybe a Source #

safeHead xs return the first element of list xs if it is not empty and Nothing otherwise.

>>> safeHead []
Nothing
>>> safeHead [1]
Just 1
>>> safeHead [1..5]
Just 1

safeLast :: [a] -> Maybe a Source #

safeHead xs return the last element of list xs if it is not empty and Nothing otherwise.

>>> safeLast []
Nothing
>>> safeLast [1]
Just 1
>>> safeLast [1..5]
Just 5

String

trim :: String -> String Source #

trim xs deletes the leading and trailing whitespace of xs.

>>> trim "  ab c de  "
"ab c de"
>>> trim "  ab c de"
"ab c de"
>>> trim "ab c de  "
"ab c de"
>> trim "  "
""