Created
March 19, 2019 21:52
-
-
Save dmwit/a09f1535e499c5a8a675795bee8e75fb 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 QuantifiedConstraints #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE DataKinds #-} | |
import GHC.Exts | |
type family AllAllowed k xs where | |
AllAllowed k '[] = () | |
AllAllowed k (x : xs) = (Allowed k x, AllAllowed k xs) | |
class Category k where | |
type Allowed k a :: Constraint | |
type Allowed k a = () | |
id :: Allowed k a => k a a | |
(.) :: AllAllowed k [a,b,c] => k b c -> k a b -> k a c | |
class (Category k, forall a b. (Allowed k a, Allowed k b) => Allowed k (a, b)) => Monoidal k where | |
x :: AllAllowed k [a,b,c,d] => k a c -> k b d -> k (a,b) (c,d) | |
instance Category (->) where | |
id = \x -> x | |
f . g = \x -> f (g x) | |
instance Monoidal (->) where | |
x f g (a,b) = (f a, g b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment