Add Monoid instance for Symbol

This commit is contained in:
Lysxia 2020-03-03 22:20:16 -05:00
parent 3108efe96f
commit 2982fcb99e
2 changed files with 18 additions and 0 deletions

View File

@ -1,4 +1,5 @@
{-# LANGUAGE
CPP,
DataKinds,
PolyKinds,
TypeFamilies,
@ -23,6 +24,10 @@ import Fcf.Core (Exp, Eval)
import Data.Monoid (All(..), Any(..))
import Data.Type.Bool (type (&&), type (||))
#if __GLASGOW_HASKELL__ >= 802
import GHC.TypeLits (AppendSymbol)
#endif
-- $setup
-- >>> import GHC.TypeLits (Nat)
@ -66,6 +71,12 @@ type instance (<>) ('All a) ('All b) = 'All (a && b)
-- Any
type instance (<>) ('Any a) ('Any b) = 'Any (a || b)
#if __GLASGOW_HASKELL__ >= 802
-- Symbol
-- | With /base >= 4.10.0.0/.
type instance (<>) x y = AppendSymbol x y
#endif
-- | Type-level monoid identity 'Data.Monoid.mempty'.
--
-- This is the fcf-encoding of 'MEmpty'.
@ -112,3 +123,6 @@ type instance MEmpty = 'All 'True
-- Any
type instance MEmpty = 'Any 'False
-- Symbol
type instance MEmpty = ""

View File

@ -1,4 +1,5 @@
{-# LANGUAGE
CPP,
DataKinds,
KindSignatures,
TypeOperators #-}
@ -64,6 +65,9 @@ _ = Refl :: Eval ('LT .<> 'GT) :~: 'LT
_ = Refl :: Eval ('EQ .<> 'GT) :~: 'GT
_ = Refl :: Eval ('Monoid.All 'True .<> 'Monoid.All 'False) :~: 'Monoid.All 'False
_ = Refl :: Eval ('Monoid.Any 'True .<> 'Monoid.Any 'False) :~: 'Monoid.Any 'True
#if __GLASGOW_HASKELL__ >= 802
_ = Refl :: Eval ("a" .<> MEmpty) :~: "a"
#endif
-- ** Foldable