Get code compiling again

Changes due to PureScript 0.15
1. Remove constraints from foreign imports.
2. Remove support for records due to the new apartness check.
3. Convert CommonJS to ESmodules

Others:
Format all files.

TODO:
Records are currently not supported because of the new apartness check
in PureScript 0.15. The instance (Typeable (f a)) then partially
overlaps with (Typeable (Record r)). Even though (a::Type) and (r::Row
Type), that still isn't enough for the compiler to disambiguate. There
is no way that I can see to specify an instance for all (f a) where f is
NOT Record.
This commit is contained in:
Anupam Jain
2023-07-04 18:17:36 +05:30
parent 696d538d05
commit 7a785fccb5
5 changed files with 121 additions and 59 deletions

View File

@@ -1,5 +1,5 @@
exports.clog = function(x) {
return function() {
console.log(x);
};
};
export function clog(x) {
return function() {
console.log(x);
};
}

View File

@@ -17,12 +17,13 @@ foreign import clog :: forall a. a -> Effect Unit
assert :: forall m. MonadThrow Error m => Boolean -> m Unit
assert = shouldEqual true
deny :: forall m. MonadThrow Error m => Boolean -> m Unit
deny = shouldEqual false
main :: Effect Unit
main = do
launchAff_ $ runSpec [consoleReporter] do
launchAff_ $ runSpec [ consoleReporter ] do
describe "Typeable" do
it "can handle primitives" do
deny $ eqTypeRep (typeRep :: _ Int) (typeRep :: _ Char)
@@ -40,48 +41,58 @@ main = do
assert $ eqTypeRep (typeRep :: _ (Either Int Person)) (typeRep :: _ (Either Int Person))
assert $ eqTypeRep (typeRep :: _ (Array Person)) typeArrPerson
deny $ eqTypeRep (typeRep :: _ (Array Person2)) typeArrPerson
it "can handle bare records" do
assert $ eqTypeRep typeRecord (typeRep :: _ {name::String, age::Int})
-- it "can handle bare records" do
-- assert $ eqTypeRep typeRecord (typeRep :: _ { name :: String, age :: Int })
it "can generate type reps from values" do
assert $ eqTypeRep (typeRep :: _ (Optional Int)) (typeRepFromVal (Some 1))
deny $ eqTypeRep (typeRep :: _ (Optional Person)) (typeRepFromVal (Some 1))
clog (eqTypeRep (typeRep :: _ Int) (typeRep :: _ Char))
clog (eqTypeRep (typeRep :: _ Int) (typeRep :: _ Int))
clog (typeRep :: _ Char)
clog (typeRep :: _ Int)
-- 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 (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 :: _ (Foo Int Int Int))
clog (typeRep :: _ Array)
-- clog (typeRep :: _ { name :: String, age :: Int })
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 :: _ (Foo Int Int Int))
where
typeRecord :: TypeRep {age::Int, name::String}
typeRecord = typeRep
typeArrPerson :: TypeRep (Array Person)
typeArrPerson = typeRep
typePerson :: TypeRep Person
typePerson = typeRep
-- The following should not compile since Break does not have a typeable instance
-- typeRecordBreak :: TypeRep {break::Break, name::String}
-- typeRecordBreak = typeRep
-- typeRecord :: TypeRep { age :: Int, name :: String }
-- typeRecord = typeRep
typeArrPerson :: TypeRep (Array Person)
typeArrPerson = typeRep
typePerson :: TypeRep Person
typePerson = typeRep
-- The following should not compile since Break does not have a typeable instance
-- typeRecordBreak :: TypeRep {break::Break, name::String}
-- typeRecordBreak = typeRep
-- 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 tagFoo :: TagT Foo where tagT = proxyT
instance tagFoo :: TagT Foo where
tagT = proxyT
newtype Person = Person { name :: String, location :: String }
instance tagTPerson :: TagT Person where tagT = proxyT
instance tagTPerson :: TagT Person where
tagT = proxyT
newtype Person2 = Person2 { name :: String, location :: String }
instance tagTPerson2 :: TagT Person2 where tagT = proxyT
instance tagTPerson2 :: TagT Person2 where
tagT = proxyT
data Optional a = None | Some a
instance tagOptional :: TagT Optional where tagT = proxyT
instance tagOptional :: TagT Optional where
tagT = proxyT