Created
March 9, 2014 23:07
-
-
Save tonymorris/9456369 to your computer and use it in GitHub Desktop.
FirstNothing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FirstNothing where | |
| -- $setup | |
| -- >>> import Test.QuickCheck | |
| -- >>> instance Arbitrary a => Arbitrary (FirstNothing a) where arbitrary = fmap FirstNothing arbitrary | |
| newtype FirstNothing a = | |
| FirstNothing (Maybe a) | |
| deriving (Eq, Show) | |
| class Semigroup a where | |
| (<>) :: | |
| a | |
| -> a | |
| -> a | |
| -- | | |
| -- | |
| -- prop> ((x <> y) <> z) == (x <> (y <> (z :: FirstNothing Int))) | |
| instance Semigroup (FirstNothing a) where | |
| FirstNothing Nothing <> _ = | |
| FirstNothing Nothing | |
| FirstNothing (Just x) <> FirstNothing (Just _) = | |
| FirstNothing (Just x) | |
| FirstNothing (Just _) <> FirstNothing Nothing = | |
| FirstNothing Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment