gdritter repos pico-ml-old / master README.md
master

Tree @master (Download .tar.gz)

README.md @master

c7bf7f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
# PicoML

A minimal statically-typed functional programming language. Not actually
an ML. Written entirely in cross-platform C; allows for multiple code
generators.

Exhaustive feature list:

- sums (eager)
- products (lazy)
- functions
  - currying
  - closures
- references
- implicit values (searched by type, must be unambiguous)
- libc bindings (incl. malloc)

Maybe looking like

~~~~
data List a =
  [ Cons a (List a)
  , Nil
  ]

map (f : a -> b) (l : List a) : List b =
  case l of
    Cons x xs -> Cons (f x) (map f xs)
    Nil       -> Nil

record Stream a =
  { .head a
  , .tail (Stream a)
  }

mapS (f : a -> b) (s : Stream a) : Stream b =
  { .head = f s.head
  , .tail = mapS f s.tail
  }

record Functor f = { .fmap ((a -> b) -> f a -> f b)  }

implicit listFunctor   : Functor List   = { .fmap = map  }
implicit streamFunctor : Functor Stream = { .fmap = mapS }
~~~~