gdritter repos pico-ml-old / master stdlib / Collections.pml
master

Tree @master (Download .tar.gz)

Collections.pml @masterraw · history · blame

exports
  Functor(..)
  HasLength(..)
  Sequence(..)
  length
  map
  null

record HasLength f = .length (f -> Nat)

length : implicit (HasLength l) -> l -> Nat
  l = l.length

null : implicit (HasLength l) -> l -> Bool
  l ls = l.length ls == 0

record Sequence f =
  .toList   (f a    -> List a)
  .fromList (List a -> f a)

record Functor f = .map ((a -> b) -> f a -> f b)

map : implicit (Functor f) -> (a -> b) -> f a -> f b
  f = f.map