mirror of
https://github.com/Lysxia/first-class-families.git
synced 2024-09-11 19:47:12 +03:00
Add Monoid instance for Symbol
This commit is contained in:
parent
3108efe96f
commit
2982fcb99e
@ -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 = ""
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user