tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

practical-support.tri (922B)


      1 -- Explicit standalone-environment fixture for adapter/authentication tests.
      2 -- Current examples declare native imports instead of receiving this profile.
      3 -- Preparation supplies existing binary arithmetic, canonical-natural and Boolean
      4 -- predicates from the accepted library; do not duplicate those algorithms here.
      5 true = t t
      6 false = t
      7 natural? = isNat?
      8 lessEq = lte_?
      9 addBinary = add
     10 
     11 scalar? char = case natural? char of
     12   ^true = and? (lessEq char 1114111) (not? (and? (lessEq 55296 char) (lessEq char 57343)))
     13   _ = false
     14 
     15 text? [] = true
     16 text? [char | rest] = case scalar? char of
     17   ^true = text? rest
     18   _ = false
     19 text? _ = false
     20 
     21 -- Scalar record: [fieldName tag value], where tags 0/1/2 mean text/natural/bool.
     22 stringField name value = [name 0 value]
     23 numberField name value = [name 1 value]
     24 boolField name value = [name 2 value]
     25 failure message = [(stringField "status" "error") (stringField "message" message)]