Created
March 14, 2016 20:27
-
-
Save amitaibu/7eb4e6798347a1dd353f to your computer and use it in GitHub Desktop.
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 Example where | |
import Data.Semigroup | |
import Test.QuickCheck | |
data Trivial = Trivial deriving (Eq, Show) | |
instance Semigroup Trivial where | |
_ <> _ = Trivial | |
instance Arbitrary Trivial where | |
arbitrary = return Trivial | |
newtype Identity a = Identity a deriving (Eq, Show) | |
instance Semigroup (Identity a) where | |
x <> y = x | |
instance (Num a) => Arbitrary (Identity a) where | |
arbitrary = undefined | |
newtype BoolConj = BoolConj Bool deriving (Eq, Show) | |
instance Semigroup BoolConj where | |
BoolConj x <> BoolConj y = BoolConj $ x || y | |
instance Arbitrary BoolConj where | |
arbitrary = elements [BoolConj True, BoolConj False] | |
semigroupAssoc :: (Eq m, Semigroup m) => m -> m -> m -> Bool | |
semigroupAssoc a b c = (a <> (b <> c)) == ((a <> b) <> c) | |
type TrivialAssoc = Trivial -> Trivial -> Trivial -> Bool | |
type BoolConjAssoc = BoolConj -> BoolConj -> BoolConj -> Bool | |
main :: IO () | |
main = do | |
quickCheck (semigroupAssoc :: TrivialAssoc) | |
-- @todo: | |
-- quickCheck (semigroupAssoc :: Identity Int -> Identity Int -> Identity Int -> Bool) | |
quickCheck (semigroupAssoc :: BoolConjAssoc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment