Use polykinds in Purescript 0.14

This commit is contained in:
Anupam Jain
2021-04-22 16:10:00 +05:30
parent d6a4c80b81
commit 1eabe79427
7 changed files with 382 additions and 161 deletions

View File

@@ -3,26 +3,34 @@ module Test.Main where
import Prelude
import Data.Either (Either)
import Data.Typeable (class Tag0, class Tag1, class Tag3, TypeRep, eqTypeRep, proxy0, proxy1, proxy3, typeRep, typeRepFromVal)
import Data.Typeable (class TagT, TypeRep, eqTypeRep, proxyT, typeRep, typeRepFromVal)
import Effect (Effect)
foreign import clog :: forall a. a -> Effect Unit
main :: Effect Unit
main = do
clog (eqTypeRep (typeRep :: _ Int) (typeRep :: _ Char))
clog (eqTypeRep (typeRep :: _ Int) (typeRep :: _ Int))
clog (typeRep :: _ Char)
clog (typeRep :: _ Int)
clog (typeRep :: _ Array)
clog (typeRep :: _ {name::String, age::Int})
clog (eqTypeRep typeRecord (typeRep :: _ {name::String, age::Int}))
clog (eqTypeRep (typeRep :: _ Person) typePerson)
clog (eqTypeRep (typeRep :: _ (Array Person)) typeArrPerson)
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 :: _ (Int -> Either (Either Int Int) (Optional (Array (Person)))))
clog (typeRep :: _ (Either (Either Int Int) (Optional (Array (Person)))))
clog (typeRep :: _ (Either Int Int))
clog (typeRep :: _ Int)
clog (typeRep :: _ (Foo Int Int Int))
clog (eqTypeRep (typeRep :: _ Array) (typeRep :: _ Array))
clog (eqTypeRep (typeRep :: _ Person) typePerson)
clog (eqTypeRep (typeRep :: _ (Array Person)) typeArrPerson)
clog (eqTypeRep (typeRep :: _ (Array Person2)) typeArrPerson)
clog (eqTypeRep typeRecord (typeRep :: _ {name::String, age::Int}))
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)))
where
typeRecord :: TypeRep {age::Int, name::String}
typeRecord = typeRep
@@ -37,14 +45,15 @@ main = do
-- A data type without a typeable instance
data Break
data Foo :: forall k1 k2 k3. k1 -> k2 -> k3 -> Type
data Foo a b c = Foo
instance tag3Foo :: Tag3 Foo where tag3 = proxy3
instance tagFoo :: TagT Foo where tagT = proxyT
newtype Person = Person { name :: String, location :: String }
instance tag0Person :: Tag0 Person where tag0 = proxy0
instance tagTPerson :: TagT Person where tagT = proxyT
newtype Person2 = Person2 { name :: String, location :: String }
instance tag0Person2 :: Tag0 Person2 where tag0 = proxy0
instance tagTPerson2 :: TagT Person2 where tagT = proxyT
data Optional a = None | Some a
instance tag1Optional :: Tag1 Optional where tag1 = proxy1
instance tagOptional :: TagT Optional where tagT = proxyT