packages feed

egison-4.0.0: lib/core/base.egi

--
--
-- Base
--
--

eq :=
  matcher
    | #$val as () with
      | $tgt -> if val = tgt then [()] else []
    | $ as (something) with
      | $tgt -> [tgt]

bool := eq
char := eq
integer := eq
float := eq

--
-- Utility
--

id := 1#%1

fst := 2#%1

snd := 2#%2

apply f x := f x

compose f g := \x -> g (f x)

flip fn := \$x $y -> fn y x

eqAs a x y :=
  match x as a with
    | #y -> True
    | _ -> False

--
-- Boolean
--

(&&) b1 b2 := if b1 then b2 else False
(||) b1 b2 := if b1 then True else b2

not b :=
  match b as bool with
    | #True -> False
    | #False -> True

--
-- Unordered Pair
--

unorderedPair m :=
  matcher
    | ($, $) as (m, m) with
      | ($x, $y) -> [(x, y), (y, x)]
    | $ as (eq) with
      | $tgt -> [tgt]