Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FromField instance for () #31

Merged
merged 1 commit into from
Jan 5, 2013
Merged

Conversation

Shimuuar
Copy link
Contributor

@Shimuuar Shimuuar commented Jan 2, 2013

It's useful in cases when one wants to ignore column's value. Quoting from documentation:

-- In order to ignore column you can use unit type '()'. It always
-- successfully decode. Note that it lacks corresponding 'ToField'
-- instance. It serves as placeholder to indicate that there's
-- something in the column you don't care what.
--
-- > case decode False "foo,1\r\nbar,22" of
-- >     Left  err -> putStrLn err
-- >     Right v   -> forM_ v $ \ ((), i) -> print (i :: Int)

@tibbe
Copy link
Collaborator

tibbe commented Jan 5, 2013

Should we perhaps be a bit more explicit and use a newtype Ignored = Ignored type instead?

Pros: Clarity
Cons: Another data type, longer to type

@tibbe tibbe merged commit ebd1bd4 into haskell-hvr:master Jan 5, 2013
@tibbe
Copy link
Collaborator

tibbe commented Jan 5, 2013

Decided to go with (). Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants