tricu

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

consumer_base_effect_pure_lambda.tri (1171B)


      1 -- Same parsed request -> Done/Await tree, with no IO in either pure case.
      2 !import "consumers.comparison.registry-lambda" L
      3 !import "consumers.effect" E
      4 !import "prelude" !Local
      5 !import "io" !Local
      6 root = "__ROOT__"
      7 notFound = E.done (pair 404 (pair "text/plain; charset=utf-8" "Not found\n"))
      8 health = E.done (pair 200 (pair "text/plain; charset=utf-8" "OK\n"))
      9 workLambdaPure request = matchPair (method target :
     10   lazyBool (_ : lazyBool (_ : health)
     11     (_ : lazyMaybe (_ : notFound)
     12       (hash : E.request "ReadBundle" (pair root hash) "registryBundle" root)
     13       (L.prefixRest "/_arboricx/bundle/hash/" target))
     14     (equal? target "/_arboricx/health"))
     15     (_ : notFound) (equal? method "GET")) request
     16 
     17 -- Post-read protocol only: success/failure tagged payloads, no name dispatch.
     18 -- Both timed operands return an IO Result of the unwrapped response wire.
     19 workLambdaReceiver input = pure (matchPair (tag payload : lazyBool
     20   (_ : ok (pair 200 (pair "application/vnd.arboricx.bundle" payload)) t)
     21   (_ : lazyBool (_ : ok (pair 404 (pair "text/plain; charset=utf-8" payload)) t)
     22     (_ : err "no matching consumer rule" t) (equal? tag 0))
     23   (equal? tag 1)) input)