packages feed

egison-2.4.2: lib/core/base.egi

;;
;; Base.egi
;;

(define $Bool
  (type
    {[,$val []
      {[$tgt (if (and (or (not val) tgt) (or val (not tgt)))
                 {[]}
                 {})]}]
     [<true> []
      {[<true> {[]}]
       [#t {[]}]
       [_ {}]}]
     [<false> []
      {[<false> {[]}]
       [#f {[]}]
       [_ {}]}]
     [_ [Something]
      {[$tgt {tgt}]}]
     }))

(define $or
  (lambda [$b1 $b2]
    (match b1 Bool
      {[<true> #t]
       [<false> b2]})))

(define $and
  (lambda [$b1 $b2]
    (match b1 Bool
      {[<true> b2]
       [<false> #f]})))

(define $not
  (lambda [$b]
    (match b Bool
      {[<true> #f]
       [<false> #t]})))

(define $Char
  (type
    {[,$c []
      {[$tgt (if (eq-c? tgt c)
                 {[]}
                 {})]}]
     [_ [Something]
      {[$tgt {tgt}]}]
     }))

(define $String
  (type
    {[,$s []
      {[$tgt (if (eq-s? tgt s)
                 {[]}
                 {})]}]
     [_ [Something]
      {[$tgt {tgt}]}]
     }))

(define $Order
  (type
    {[,$val []
      {[$tgt (if (eq? val tgt)
                 {[]}
                 {})]}]
     [<less> []
      {[<less> {[]}]
       [_ {}]}]
     [<equal> []
      {[<equal> {[]}]
       [_ {}]}]
     [<greater> []
      {[<greater> {[]}]
       [_ {}]}]
     [_ [Something]
      {[$tgt {tgt}]}]
     }))

(define $match?
  (lambda [$a]
    (lambda [$x $y]
      (match x a
        {[,y #t]
         [_ #f]}))))

(define $=
  (lambda [$a]
    (lambda [$x $y]
      (and ((match? a) x y) ((match? a) y x)))))