tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

practical-support.tri (980B)


      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 -- Retained environment probe data: [fieldName tag value].
     22 -- Tags 0/1/2 denote text/natural/bool; there is no special site output decoder.
     23 stringField name value = [name 0 value]
     24 numberField name value = [name 1 value]
     25 boolField name value = [name 2 value]
     26 failure message = [(stringField "status" "error") (stringField "message" message)]