I've just started learning about PureScript effects, and I'm stuck trying to make a function that has an EXCEPTION effect.
lengthGt5 :: forall eff. String -> Eff (err :: EXCEPTION | eff) String
lengthGt5 a = if (length a <= 5)
then throwException $ error "Word is not the right length!"
else a
main = do
word <- catchException handleShortWord (lengthGt5 "test")
log word
where
handleShortWord err = do
log (message err)
return "Defaut::casserole"
When I try and run this I get the following error
Could not match type
String
with type
Eff
( err :: EXCEPTION
| eff0
)
String
I understand that lengthGt5 needs to return a String wrapped in an Eff in the non-exception case, but I'm not sure how I can create an "empty effect wrapper" around the value a
. Am I thinking about this right?