[Haskell-cafe] Errors in non-monadic code

jabolopes at google.com jabolopes at google.com
Mon Aug 19 19:48:08 CEST 2013


Hi,

What is the proper way to implement a non-monadic function that checks
whether a given value is correct and gives a proper error message
otherwise ? What is the recommended option ?

* Either String a

check val
  | valid val = Right val
  | otherwise = Left errorMsg


* Maybe String

check val
  | valid val = Nothing
  | otherwise = Just errorMsg


Cheers,
Jose




More information about the Haskell-Cafe mailing list