hid-examples-0.5: Examples to accompany the book "Haskell in Depth"

Safe HaskellSafe
LanguageHaskell2010

ParseIP

Synopsis

Documentation

guarded :: Alternative f => (a -> Bool) -> a -> f a Source #

isLengthOf :: Int -> [a] -> Bool Source #

Checks if the list has the given length

>>> 4 `isLengthOf` [1,2,3,4]
True
>>> 0 `isLengthOf` []
True
>>> 0 `isLengthOf` [1,2,3,4]
False

parseIP :: String -> Maybe IP Source #

Parses IP address given as a String

>>> parseIP "0.0.0.0"
Just 0.0.0.0
>>> parseIP "192.168.3.15"
Just 192.168.3.15
>>> parseIP "not an IP address"
Nothing