added example generics cases

This commit is contained in:
Stephen Diehl 2015-12-13 17:44:06 -05:00
parent e48d07acd7
commit dd53d46d0f
5 changed files with 29 additions and 4 deletions

View File

@ -31,6 +31,18 @@ class GEq a where
default geq :: (Generic a, GEq' (Rep a)) => a -> a -> Bool
geq x y = geq' (from x) (from y)
instance GEq Char where geq = (==)
instance GEq Int where geq = (==)
instance GEq Float where geq = (==)
-- Base equalities
instance GEq Char where geq = (==)
instance GEq Int where geq = (==)
instance GEq Float where geq = (==)
-- Equalities derived from structure of (:+:) and (:*:)
instance GEq a => GEq (Maybe a)
instance (GEq a, GEq b) => GEq (a,b)
main :: IO ()
main = do
print $ geq 2 (3 :: Int)
print $ geq 'a' 'b'
print $ geq (Just 'a') (Just 'a')
print $ geq ('a','b') ('a', 'b')

View File

@ -0,0 +1,6 @@
Assign
------
```bash
$ stack exec assign input.test
```

View File

@ -6,7 +6,7 @@ cabal-version: >=1.10
executable assign
build-depends:
base >= 4.6 && <4.7
base >= 4.6 && <4.9
, containers >= 0.5 && <0.6
, mtl >= 2.2
default-language: Haskell2010

View File

@ -0,0 +1,6 @@
resolver: lts-3.16
packages:
- '.'
extra-deps: []
flags: {}
extra-package-dbs: []

View File

@ -0,0 +1 @@
(\x -> x)