PureScript "TypesDoNotUnify" in CI
PureScript's type checker tried to unify an expression's type with the type its context requires and failed. The "TypesDoNotUnify" error prints "Could not match type X with type Y" at the offending expression.
What this error means
spago build / purs compile fails with "Error found:" and "Could not match type X with type Y" (error code TypesDoNotUnify) under the expression.
Error found:
in module Main
Could not match type
Int
with type
String
while checking that type Int is at least as general as type StringCommon causes
A value of the wrong type is used
The expression has one type (here Int) but the context expects another (String), and PureScript performs no implicit conversion.
A type signature changed
A function or record type changed shape, so an existing call now supplies or expects a type that no longer unifies.
How to fix it
Convert or correct the value
- Read the "Could not match type" pair to see the mismatch.
- Apply the right conversion (for example
show nforInttoString). - Re-run
spago build.
import Data.Show (show)
label = show countUpdate call sites after a signature change
When a type signature changes, update every expression that constructs or consumes it so the types unify again.
How to prevent it
- Add top-level type signatures so mismatches localize.
- Build locally before pushing; PureScript rejects type errors at compile time.
- Update consumers when a record or function type changes.