Skip to content

Instantly share code, notes, and snippets.

@davidxifeng
Created July 24, 2014 07:39
Show Gist options
  • Save davidxifeng/9055f580af80d4f9f148 to your computer and use it in GitHub Desktop.
Save davidxifeng/9055f580af80d4f9f148 to your computer and use it in GitHub Desktop.
fail mzero and Parser
import Data.Csv
import Control.Monad
import Control.Applicative
-- 2014-07-24 15:26:22 fail and mzero
data Test = A | B | C
deriving (Show, Read)
instance FromField Test where
parseField "A" = pure A
parseField "B" = pure B
parseField "C" = pure C
--parseField _ = fail "wrong input"
parseField _ = mzero
tp :: Parser Test
tp = parseField "Z"
test :: Either String Test
test = runParser tp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment