Digestive Functors Question


#1

Hi all,

I’m trying to wrap my head around digestive functors but I’m a bit confused. I’m looking at the tutorial here.

I see the record User

data User = User
     { userName :: Text
     , userMail :: Text
     } deriving (Show)

and the function that defines validation

userForm :: Monad m => Form Text m User
userForm = User
     <$> "name" .: text Nothing
     <*> "mail" .: check "Not a valid email address" checkEmail (text Nothing)

checkEmail :: Text -> Bool
checkEmail = isJust . T.find (== '@')

But they kind of stop there…how exactly does one use these to validate a user?

user1 = User "" "not an email address"

validateUser :: ??? -- <- what would the return type be
validateUser =
  validate user1 userForm   -- <- does something like this exist???