Skip to content

Instantly share code, notes, and snippets.

@GideonEXE
Created June 22, 2018 15:28
Show Gist options
  • Save GideonEXE/96fb2989da66bd763bb8075cb419c540 to your computer and use it in GitHub Desktop.
Save GideonEXE/96fb2989da66bd763bb8075cb419c540 to your computer and use it in GitHub Desktop.
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