aboutsummaryrefslogtreecommitdiff
path: root/src/server/Validation.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Validation.hs')
-rw-r--r--src/server/Validation.hs18
1 files changed, 9 insertions, 9 deletions
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