mirror of
https://github.com/yaitskov/purescript-typeable.git
synced 2025-01-01 06:53:05 +00:00
Add eqSomeTypeRep
This commit is contained in:
parent
caa61a0882
commit
583a5340ef
@ -15,6 +15,7 @@ module Data.Typeable
|
||||
, SomeTypeRep(..)
|
||||
, wrapSomeTypeRep
|
||||
, unwrapSomeTypeRep
|
||||
, eqSomeTypeRep
|
||||
, ProxyT, proxyT
|
||||
, class TagT, tagT
|
||||
) where
|
||||
@ -83,13 +84,18 @@ typeRepFromVal _ = typeRep
|
||||
-- | Unindexed typereps
|
||||
data SomeTypeRep = SomeTypeRep (Exists TypeRep)
|
||||
|
||||
-- | Wrap a TypeRep into a SomeTypeRep
|
||||
wrapSomeTypeRep :: forall a. TypeRep a -> SomeTypeRep
|
||||
wrapSomeTypeRep t = SomeTypeRep (mkExists t)
|
||||
|
||||
-- | Unwrap a TypeRep
|
||||
-- | Extract a TypeRep from a SomeTypeRep
|
||||
unwrapSomeTypeRep :: forall r. SomeTypeRep -> (forall a. TypeRep a -> r) -> r
|
||||
unwrapSomeTypeRep (SomeTypeRep e) f = e # runExists f
|
||||
|
||||
-- | Compare unindexed typereps
|
||||
eqSomeTypeRep :: SomeTypeRep -> SomeTypeRep -> Boolean
|
||||
eqSomeTypeRep s1 s2 = unwrapSomeTypeRep s1 \t1 -> unwrapSomeTypeRep s2 \t2 -> eqTypeRep t1 t2
|
||||
|
||||
-- MACHINERY + INSTANCES
|
||||
|
||||
foreign import typeRepDefault0 :: forall a. TagT a => TypeRep a
|
||||
|
Loading…
Reference in New Issue
Block a user