Prisma - Fast, Modular Static Type & Spec Analyzer for Elixir & Erlang (with portable .pplt)

Hi everyone! :waving_hand:

Like many in the BEAM community, we’ve often felt the friction of running Dialyzer in our daily development workflow and CI pipelines: monolithic PLT files that take minutes to build, heavy CPU and RAM consumption, and the occasional cryptic warning or false positive on defensive clauses.

To solve this, we’ve been developing Prisma: a modern, hybrid static type analyzer for Elixir and Erlang designed for sub-second feedback, granular caching, and high developer trust.


:light_bulb: How is Prisma different?

  1. Modular .pplt Tables (No monolithic PLT rebuilds)
    Instead of baking Erlang/OTP and all your dependencies into a single 100MB+ monolithic .plt blob, Prisma introduces isolated, binary .pplt (Prisma Persistent Lookup Tables):

    • Each package in mix.lock gets its own portable .pplt.
    • Bumping or changing one dependency only recompiles that specific table.
    • At analysis time, Prisma merges dependency tables dynamically in-memory in ~15 ms, so analysis time is spent solely on your application code.
    • Package authors can even pre-build and publish .pplt files directly inside their Hex packages (mix prisma.build).
  2. Hybrid Verification (Success Typing + Gradual Typing)

    • Success Typing: Infers true domain/range contracts to spot impossible paths without requiring annotations everywhere.
    • Gradual Subtyping (~ & ≲): Strictly verifies your @spec contracts (argument types, return consistency, map shapes).
    • Oxbow / Dead Code Pruning: Flags dead parameters and impossible guard clauses with the highest degree of certainty. If Prisma flags an issue, you can refactor or remove it with confidence.
  3. First-Class Elixir Support
    Prisma reads both Erlang AST and Elixir’s native Dbgi / elixir_v1 chunks, with built-in awareness of:

    • Struct patterns (%User{})
    • Keyword lists ([key: :val])
    • String binaries (String.t()) and atoms
    • Multi-clause pattern matches and SSA variable versions

:bar_chart: Real-World Benchmarks (Hyperfine on Apple M1, Erlang/OTP 29)

We benchmarked Prisma on real production code using the official RabbitMQ repository (commit 5dacb85), comparing both the core server (234 BEAM modules) and a full monorepo of 7 applications (440 BEAM modules):

Metric Prisma (440 mod) Dialyzer (440 mod) Advantage
Wall-Clock Time 3.02 s 17.27 s 5.7× — 6.3× faster
Total CPU Time 3.25 s 67.55 s 20.8× less CPU
Peak RAM (RSS) 536 MiB 1,456.7 MiB 2.7× less memory
Instructions Retired 33.7 B 467.2 B 13.9× fewer instructions
  • Fault Detection (125 injected mutants across 5 mutation classes):
    • Prisma: Detected 125 / 125 (100%) of faults, with 0 spurious warnings outside mutated functions.
    • Dialyzer: Detected 123 / 125 (98.4%), but emitted 201 spurious warnings.
    • Gradualizer: Detected 68 / 125 (54.4%), and ran 5.3× slower on 440 modules (35.9s vs 6.8s).

:rocket: Getting Started with Mix

Adding Prisma to your project is straightforward. In your mix.exs:

def deps do
  [
    {:prisma, "~> 0.1.0", only: [:dev, :test], runtime: false}
  ]
end

Then run:

# Analyze your project
mix prisma

# Output formats for CI or editor linters
mix prisma --format human    # default rich ANSI output
mix prisma --format oneline  # ideal for vim/neovim/vscode diagnostics
mix prisma --format json     # for CI automation & bots

You can also customize settings in mix.exs:

def project do
  [
    app: :my_app,
    version: "0.1.0",
    prisma: [
      mode: :hybrid,   # :hybrid | :gradual | :discrepancy
      oxbow: true,     # dead code / unused parameter detection
      format: :human
    ],
    deps: deps()
  ]
end

:link: Links & Community Feedback

  • GitHub:

We would love for you to try it out on your Elixir applications and libraries! Feel free to share your thoughts, report issues, or suggest improvements. What are your biggest friction points with static typing in Elixir today?

12 Likes