From 70720548c9af024dbb6080638ac8e5470c2213eb Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 25 Jun 2016 15:10:03 +0200 Subject: Use the search to view either punctual or monthly payments --- src/server/Validation.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/server/Validation.hs') diff --git a/src/server/Validation.hs b/src/server/Validation.hs index 455ae5b..1f332c9 100644 --- a/src/server/Validation.hs +++ b/src/server/Validation.hs @@ -6,18 +6,18 @@ module Validation import Data.Text (Text) import qualified Data.Text as T -nonEmpty :: a -> Text -> Either a Text -nonEmpty x str = +nonEmpty :: Text -> Maybe Text +nonEmpty str = if T.null str - then Left x - else Right str + then Nothing + else Just str -number :: x -> (Int -> Bool) -> Text -> Either x Int -number x numberForm str = +number :: (Int -> Bool) -> Text -> Maybe Int +number numberForm str = case reads (T.unpack str) :: [(Int, String)] of (num, _) : _ -> if numberForm num - then Right num - else Left x + then Just num + else Nothing _ -> - Left x + Nothing -- cgit v1.2.3