symantic: Library for Typed Tagless-Final Higher-Order Composable DSL

[ gpl, language, library ] [ Propose Tags ]


This is an experimental library for composing, parsing, typing, compiling, transforming and interpreting a custom DSL (Domain-Specific Language) expressing a subset of GHC's Haskell type system:

where "chosen X" means declared in Haskell and selected when composing the DSL.

In particular, this library is currently not able to:

And by itself, the DSL is only able to define new terms to be interpreted, no new types, or other type-level structures.


Please be aware that despite its using of powerful ideas from clever people, this remains a FUND-LESS SINGLE-PERSON EXPERIMENTAL LIBRARY. Meaning that it IS NOT heavily tested and documented, DOES NOT have a strong commitment to preserving backward compatibility, MAY FAIL to comply with the PVP, and CAN die without notice. You've been warned.

Use cases

The main goal of this library is to enable the runtime interpretation of terms, type-checked according to some types defined at composing-time (ie. GHC's compile-time).

Using a DSL enables to limit expressiveness in order to ease analysis. Here the idea is that the more complex logic shall remain written in Haskell, and then this library used to project an interface into a DSL (using GHC's Haskell as a FFI (Foreign Function Interface)). This in order to give runtime users the flexibility to write programs not requiring a full-blown Haskell compiler, yet enabling enough flexibility to let them express complex needs with a reasonably advanced type-safe way and a controlled environment of primitives.

Typical use cases:


Please pick in symantic-lib a few specific Lib/*.hs files near what you want to do and the corresponding Lib/*/Test.hs file, if any in the Git repository, to learn by examples how to use this library.

Those Lib/*/Test.hs files use megaparsec as parser (see Grammar/Megaparsec.hs) and a default grammar somehow sticking to Haskell's, but staying context-free (so in particular: insensitive to the indentation), and supporting prefix and postfix operators. This grammar — itself written as a symantic embedded DSL with symantic-grammar — can be reused to build other ones, is not bound to a specific parser, and can produce its own EBNF rendition.


This library would probably be much worse than it is without the following seminal works:

Main ideas

Main extensions


There are some of them hidding in there, and the whole thing is far from being perfect… Your comments, problem reports, or questions, are welcome! You have my email address, so… just send me some emails :]

To do

Versions [faq],,,,,,,
Dependencies base (>=4.6 && <5), containers, ghc-prim, mono-traversable, symantic-document, symantic-grammar, text, transformers [details]
License GPL-3.0-only
Author Julien Moutinho <>
Maintainer Julien Moutinho <>
Category Language
Bug tracker Julien Moutinho <>
Source repo head: git clone git://
Uploaded by julm at 2017-06-23T18:05:14Z
Distributions NixOS:
Downloads 3638 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-06-23 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees