Skip to content

Instantly share code, notes, and snippets.

@sjoerdvisscher
Created September 24, 2018 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjoerdvisscher/f60ffb9ed61ccffa9a28c1e89b9b9616 to your computer and use it in GitHub Desktop.
Save sjoerdvisscher/f60ffb9ed61ccffa9a28c1e89b9b9616 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeOperators, TypeFamilies, FlexibleInstances, MultiParamTypeClasses, ConstraintKinds, UndecidableSuperClasses #-}
import GHC.Generics
import Data.Algebra
class (a x, b x) => (a + b) x
instance (a x, b x) => (a + b) x
type instance Signature (a + b) = Signature a :+: Signature b
instance (AlgebraSignature f, AlgebraSignature g) => AlgebraSignature (f :+: g) where
type Class (f :+: g) = Class f + Class g
evaluate (L1 f) = evaluate f
evaluate (R1 f) = evaluate f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment