Created
March 26, 2018 12:37
-
-
Save chessai/14ca32e8d0331e0c625fa1169bde50a6 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
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE PolyKinds #-} | |
class Semiring a where | |
zero :: a | |
one :: a | |
plus :: a -> a -> a | |
times :: a -> a -> a | |
class SemiringForall (f :: k -> *) where | |
zeroForall :: f a | |
oneForall :: f a | |
plusForall :: f a -> f a -> f a | |
timesForall :: f a -> f a -> f a | |
class Semiring1 (f :: * -> *) where | |
liftZero :: a -> f a | |
liftOne :: a -> f a | |
liftPlus :: (a -> a -> a) -> f a -> f a -> f a | |
liftTimes :: (a -> a -> a) -> f a -> f a -> f a | |
zero1, one1 :: (Semiring1 f, Semiring a) => f a | |
zero1 = liftZero zero | |
one1 = liftOne one | |
plus1, times1 :: (Semiring1 f, Semiring a) => f a -> f a -> f a | |
plus1 = liftPlus plus | |
times1 = liftTimes times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment