{-# LANGUAGE
DataKinds,
PolyKinds,
TypeFamilies,
TypeInType,
TypeOperators,
UndecidableInstances #-}
module Fcf.Class.Monoid
(
type (<>)
, MEmpty
, type (.<>)
, MEmpty_
) where
import Fcf.Core (Exp, Eval)
import Data.Monoid (All(..), Any(..))
import Data.Type.Bool (type (&&), type (||))
data (.<>) :: a -> a -> Exp a
type instance Eval (x .<> y) = x <> y
type family (<>) (x :: a) (y :: a) :: a
type instance (<>) '(a1, a2) '(b1, b2) = '(a1 <> b1, a2 <> b2)
type instance (<>) '(a1, a2, a3) '(b1, b2, b3) = '(a1 <> b1, a2 <> b2, a3 <> b3)
type instance (<>) '[] ys = ys
type instance (<>) (x ': xs) ys = x ': (<>) xs ys
type instance (<>) 'Nothing b = b
type instance (<>) a 'Nothing = a
type instance (<>) ('Just a) ('Just b) = 'Just (a <> b)
type instance (<>) 'EQ b = b
type instance (<>) a 'EQ = a
type instance (<>) 'LT _b = 'LT
type instance (<>) 'GT _b = 'GT
type instance (<>) _a _b = '()
type instance (<>) ('All a) ('All b) = 'All (a && b)
type instance (<>) ('Any a) ('Any b) = 'Any (a || b)
data MEmpty_ :: Exp a
type instance Eval MEmpty_ = MEmpty
type family MEmpty :: a
type instance MEmpty = '(MEmpty, MEmpty)
type instance MEmpty = '(MEmpty, MEmpty, MEmpty)
type instance MEmpty = '[]
type instance MEmpty = 'Nothing
type instance MEmpty = 'EQ
type instance MEmpty = '()
type instance MEmpty = 'All 'True
type instance MEmpty = 'Any 'False