Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kseo/poly_constraints
Hindley-Milner type inference using constraints
https://github.com/kseo/poly_constraints
Last synced: 10 days ago
JSON representation
Hindley-Milner type inference using constraints
- Host: GitHub
- URL: https://github.com/kseo/poly_constraints
- Owner: kseo
- License: mit
- Created: 2017-01-02T16:20:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-02T16:21:05.000Z (almost 8 years ago)
- Last Synced: 2024-10-12T23:22:30.369Z (26 days ago)
- Language: Haskell
- Size: 13.7 KB
- Stars: 48
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Poly
====A simple ML dialect with definitions, let polymorphism and a fixpoint operator.
Uses syntax directed HM type inference.To compile and run:
```shell
$ cabal run
```Usage:
```ocaml
Poly> let i x = x;
i : forall a. a -> aPoly> i 3
3Poly> :type i
i : forall a. a -> aPoly> :type let k x y = x;
k : forall a b. a -> b -> aPoly> :type let s f g x = f x (g x)
s : forall a b c. ((a -> b) -> c -> a) -> (a -> b) -> c -> bPoly> :type let on g f = \x y -> g (f x) (f y)
on : forall a b c. (a -> a -> b) -> (c -> a) -> c -> c -> bPoly> :type let let_bound = i (i i) (i 3)
let_bound : IntPoly> :type let compose f g = \x -> f (g x)
compose : forall a b c. (a -> b) -> (c -> a) -> c -> bPoly> let rec factorial n =
if (n == 0)
then 1
else (n * (factorial (n-1)));
```Notes
=====Top level let declarations are syntactic sugar for nested lambda. For example:
```ocaml
let add x y = x + y;
```Is semantically equivalent to:
```ocaml
let add = \x -> \y -> x + y;
```Top level Let-rec declarations are syntactic sugar for use of the ``fix``
operator. For example:```ocaml
let rec factorial n = if (n == 0) then 1 else (n * (factorial (n-1)));
```
Is semantically equivalent to:```ocaml
let factorial = fix (\factorial n -> if (n == 0) then 1 else (n * (factorial (n-1))));
```License
=======Released under MIT license.