mirror of
https://github.com/yaitskov/purescript-typeable.git
synced 2024-11-09 23:53:05 +00:00
Minor fix
This commit is contained in:
parent
6b6258f632
commit
88b07988eb
@ -3,7 +3,7 @@ Welcome to a Spago project!
|
||||
You can edit this file as you like.
|
||||
-}
|
||||
{ name = "typeable"
|
||||
, dependencies = [ "console", "effect", "psci-support" ]
|
||||
, dependencies = [ "console", "effect", "psci-support", "either", "arrays" ]
|
||||
, packages = ./packages.dhall
|
||||
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
module Typeable where
|
||||
|
||||
import Data.Either (Either)
|
||||
import Data.Unit (Unit)
|
||||
import Effect (Effect)
|
||||
|
||||
-- Indexed Typereps
|
||||
-- Indexed TypeReps
|
||||
data TypeRep a
|
||||
|
||||
-- Typeable class
|
||||
@ -21,8 +22,8 @@ class Tag3 (a :: Type -> Type -> Type) where t3 :: Proxy3 a
|
||||
|
||||
-- Constructors for the opaque data type
|
||||
foreign import typerepImpl1 :: forall a. Tag1 a => TypeRep a
|
||||
foreign import typerepImpl2 :: forall a b. Typeable b => Tag2 a => TypeRep (a b)
|
||||
foreign import typerepImpl3 :: forall a b c. Typeable c => Typeable b => Tag1 c => TypeRep (a b c)
|
||||
foreign import typerepImpl2 :: forall a b. Tag2 a => Typeable b => TypeRep (a b)
|
||||
foreign import typerepImpl3 :: forall a b c. Tag3 a => Typeable b => Typeable c => TypeRep (a b c)
|
||||
|
||||
-- Type equality
|
||||
foreign import eqTypeRep :: forall a b. TypeRep a -> TypeRep b -> Boolean
|
||||
@ -32,6 +33,8 @@ instance tag1Int :: Tag1 Int where t1 = Proxy1
|
||||
instance typeableInt :: Typeable Int where typeRep = typerepImpl1
|
||||
instance tag2Array :: Tag2 Array where t2 = Proxy2
|
||||
instance typeableArray :: Typeable a => Typeable (Array a) where typeRep = typerepImpl2
|
||||
instance tag3Either :: Tag3 Either where t3 = Proxy3
|
||||
instance typeableEither :: (Typeable a, Typeable b) => Typeable (Either a b) where typeRep = typerepImpl3
|
||||
|
||||
-- DEBUG: Console.log anything
|
||||
foreign import clog :: forall a. a -> Effect Unit
|
||||
|
@ -2,6 +2,7 @@ module Test.Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Either (Either)
|
||||
import Effect (Effect)
|
||||
import Typeable (class Tag1, class Tag2, class Typeable, Proxy1(..), Proxy2(..), TypeRep, clog, eqTypeRep, typeRep, typerepImpl1, typerepImpl2)
|
||||
|
||||
@ -11,6 +12,8 @@ main = do
|
||||
clog (eqTypeRep (typeRep :: _ (Array Person2)) typeArrPerson)
|
||||
clog (eqTypeRep (typeRep :: _ (Optional Int)) (typeRepFromVal (Some 1)))
|
||||
clog (eqTypeRep (typeRep :: _ (Optional Person)) (typeRepFromVal (Some 1)))
|
||||
clog (eqTypeRep (typeRep :: _ (Either Int Person)) (typeRep :: _ (Either Int Person)))
|
||||
clog (typeRep :: _ (Either (Either Int Int) (Optional (Array (Person)))))
|
||||
where
|
||||
typeArrPerson :: TypeRep (Array Person)
|
||||
typeArrPerson = typeRep
|
||||
|
Loading…
Reference in New Issue
Block a user