Skip to content

Instantly share code, notes, and snippets.

@adinapoli
Created September 14, 2012 16:58
Show Gist options
  • Save adinapoli/3723225 to your computer and use it in GitHub Desktop.
Save adinapoli/3723225 to your computer and use it in GitHub Desktop.
createUser :: Text -- ^ Username
-> ByteString -- ^ Password
-> Handler b (AuthManager b) (Either String AuthUser)
createUser "" _ = return $ Left "Username cannot be empty"
createUser unm pwd = withBackend (\r -> liftM (\x -> Right x) $ liftIO $ buildAuthUser r unm pwd)
@adinapoli
Copy link
Author

It yield the correct type, but it's ugly.

a) How to beautify that liftM?
b) Is it convenient to create a type synonym like BackendStoreFailure or something like that opposed to String which doesn't characterize what's going on?

@adinapoli
Copy link
Author

It yields the correct type, but it's ugly.

a) How to beautify that liftM?
b) Is it convenient to create a type synonym like BackendStoreFailure or something like that opposed to String which doesn't characterize what's going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment