Skip to content
Latchkey

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.

PureScript
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 String

Common 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

  1. Read the "Could not match type" pair to see the mismatch.
  2. Apply the right conversion (for example show n for Int to String).
  3. Re-run spago build.
src/Main.purs
import Data.Show (show)

label = show count

Update 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →