module Validation ( nonEmpty , number ) where import Data.Text (Text) import qualified Data.Text as T nonEmpty :: Text -> Maybe Text nonEmpty str = if T.null str then Nothing else Just str number :: (Int -> Bool) -> Text -> Maybe Int number numberForm str = case reads (T.unpack str) :: [(Int, String)] of (num, _) : _ -> if numberForm num then Just num else Nothing _ -> Nothing