tricu

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

workers.tri (1065B)


      1 !import base *
      2 !import intensional *
      3 !import server as Registry
      4 !export *
      5 
      6 uncheckedHead input = matchList t (h _ : h) input
      7 checkedHead input = bindResult (checkContract (nonEmptyListOf anyC) input) (xs _ : ok (matchList t (h _ : h) xs) t)
      8 guardedDiv input = div 10 input
      9 checkedDiv input = bindResult (checkContract nonZero? input) (n _ : ok (div 10 n) t)
     10 sortedMaximum input = bindResult (checkContract (sortedList? nat?) input) (xs _ : ok (foldl max 0 xs) t)
     11 evenHalf input = bindResult (checkContract evenC? input) (n _ : ok (div n 2) t)
     12 sortedSum input = bindResult (withContract (sortedList? nat?) input) (xs _ : ok (sum xs) t)
     13 naturalSum input = bindResult (withContract (listOf nat?) input) (xs _ : ok (sum xs) t)
     14 checkedAdd input = bindResult (fn2 nat? nat? nat? add t) (f _ : bindResult (f input t) (g _ : g 5 t))
     15 checkedIdentity input = bindResult (fnContract nat? nat? (x : x) t) (f _ : f input t)
     16 
     17 uncheckedHash input = true
     18 inlineHash input = Registry.bundleHashValid? input
     19 contractHash input = resultIsOk (checkContract Registry.bundleHashC input)