LLM approve #1
This commit is contained in:
45
lib/base.tri
45
lib/base.tri
@@ -119,6 +119,47 @@ maybeBind m f = matchMaybe nothing f m
|
||||
maybeOr default m = matchMaybe default id m
|
||||
maybe? = matchMaybe false (_ : true)
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Lazy eliminators
|
||||
--
|
||||
-- A strict eliminator evaluates both branches because they are ordinary
|
||||
-- arguments. Give a branch that recurses, looks something up, or builds
|
||||
-- structure to one of these instead: it becomes a thunk and only the selected
|
||||
-- branch is ever applied.
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
lazyBool = (thenK elseK cond :
|
||||
((chosen : chosen t)
|
||||
(matchBool
|
||||
thenK
|
||||
elseK
|
||||
cond)))
|
||||
|
||||
-- This module has no list matcher, so `triage` is used directly: a cons is a
|
||||
-- Fork, which is why the cons case sits in the fork slot, exactly as in
|
||||
-- `matchList` in lib/list.tri.
|
||||
lazyList = (nilK consK xs :
|
||||
((chosen : chosen t)
|
||||
(triage
|
||||
nilK
|
||||
_
|
||||
(h r : (_ : consK h r))
|
||||
xs)))
|
||||
|
||||
lazyMaybe = (noneK someK m :
|
||||
((chosen : chosen t)
|
||||
(matchMaybe
|
||||
noneK
|
||||
(x : (_ : someK x))
|
||||
m)))
|
||||
|
||||
lazyResult = (errK okK result :
|
||||
((chosen : chosen t)
|
||||
(matchResult
|
||||
(code rest : (_ : errK code rest))
|
||||
(value rest : (_ : okK value rest))
|
||||
result)))
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Basic arithmetic
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -217,7 +258,3 @@ resultMapErr = (f result :
|
||||
(code rest : err (f code) rest)
|
||||
(value rest : ok value rest)
|
||||
result)
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- View facts
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user