yesod-filter-0.1.0.2: Automatic filter generator for Yesod

Safe HaskellSafe
LanguageHaskell2010

Yesod.Filter.Read

Synopsis

Documentation

readMaybeInt :: String -> Maybe Int Source #

Parse a string to Int.

>>> readMaybeInt "1"
Just 1
>>> readMaybeInt "one"
Nothing

readMaybeDouble :: String -> Maybe Double Source #

Parse a string to Double.

>>> readMaybeDouble "1.0"
Just 1.0
>>> readMaybeDouble "1"
Just 1.0

readMaybeBool :: String -> Maybe Bool Source #

Parse a string to Bool.

>>> readMaybeBool "true"
Just True
>>> readMaybeBool "FALSE"
Just False

readMaybeDay :: String -> Maybe Day Source #

Parse a string to Day.

>>> readMaybeDay "2020-01-01"
Just 2020-01-01
>>> readMaybeDay "2020/01/01"
Nothing

readMaybeTimeOfDay :: String -> Maybe TimeOfDay Source #

Parse a string to TimeOfDay.

>>> readMaybeTimeOfDay "12:34:56"
Just 12:34:56
>>> readMaybeTimeOfDay "12:34:56.789"
Just 12:34:56.789

readMaybeUTCTime :: String -> Maybe UTCTime Source #

Parse a string to UTCTime.

>>> readMaybeUTCTime "2020-01-01T12:34:56Z"
Just 2020-01-01 12:34:56 UTC
>>> readMaybeUTCTime "2020-01-01T12:34:56+09:00"
Nothing

readMaybe' :: Read a => String -> Maybe a Source #

Wrapper function of readMaybe that returns Nothing if a string has leading/trailing whitespaces.

>>> readMaybe' "1" :: Maybe Int
Just 1
>>> readMaybe' " 1" :: Maybe Int
Nothing
>>> readMaybe' "1 " :: Maybe Int
Nothing

capitalize :: String -> String Source #

Capitalize a string.

>>> capitalize "foo"
"Foo"
>>> capitalize "FOO"
"Foo"