0.1.9 • Published 5 years ago

hm-lang-light v0.1.9

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

JavaScript fast, lightweight parsers for Hindley-Milner type expressions using Parsimmon for parsers formulation.

Features

  • Is able to parse all Sanctuary and Fantasy Land type declarations
  • Only one self-contained dependency
  • Clear and extensible
  • Fast combinator parsing
  • About 1.8k LoC total
  • More comprehensive tests

Examples

import HMLang from "hm-lang-light"
import _runP  from "hm-lang-light/run-parser"

const runP    = _runP (HMLang)

runP ("declaration")
     ("ap :: Applicative m => m (a -> b) -> m a -> m b")

HMLang.declaration
  .tryParse("reverse :: (Applicative f, Foldable f, Monoid (f a)) => f a -> f a")

// Method -with complex type signature-
runP ("declaration")
     ("traverse :: (Applicative f, Traversable t) => t a ~> (TypeRep f, a -> f b) -> f (t b)")

// Record syntax sugar
runP ("declaration")
     ("hello :: a -> { x :: String, y :: a }")

// `FlexibleContexts` enabled by design, also supporting record syntax
HMLang.constraint
  .parse("M (a -> b) {c :: Int}") // {status: true, ...}

See tests for more examples.

License

This project is licensed under the MIT License - see the LICENSE file for details.

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago