Created
June 22, 2018 15:28
-
-
Save GideonEXE/96fb2989da66bd763bb8075cb419c540 to your computer and use it in GitHub Desktop.
This file contains 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 Main where | |
import Lib | |
import Data.List | |
main :: IO () | |
main = someFunc | |
add :: Integer -> Integer -> Integer | |
add a b = | |
a + b | |
addOne :: Integer -> Integer | |
addOne a = | |
add a 1 | |
swap :: (a, b) -> (b, a) | |
swap (x, y) = | |
(y, x) | |
class SemiGroup a where | |
combine :: a -> a -> a | |
instance SemiGroup Integer where | |
combine x y = | |
add x y | |
instance SemiGroup Bool where | |
combine x y = | |
x || y | |
class MyMonoid a where | |
myId :: a | |
myJoin :: a -> a -> a | |
instance MyMonoid Integer where | |
myId = 0 | |
myJoin x y = | |
add x y | |
checkAssociativity :: (Eq a, MyMonoid a) => a -> a -> a -> Bool | |
checkAssociativity x y z = | |
myJoin x (myJoin y z) == myJoin (myJoin x y) z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment