Back out the worst of the unsound nonsense
This commit is contained in:
174
lib/base.tri
174
lib/base.tri
@@ -1,8 +1,8 @@
|
||||
false = t
|
||||
_ = t
|
||||
true = t t
|
||||
id a@_a =@_a a
|
||||
const a@_a b@_b =@_a a
|
||||
id a = a
|
||||
const a b = a
|
||||
pair = t
|
||||
if cond then else = t (t else (t t then)) t cond
|
||||
|
||||
@@ -10,7 +10,7 @@ y = ((mut wait fun : wait mut (x : fun (wait mut x)))
|
||||
(x : x x)
|
||||
(a0 a1 a2 : t (t a0) (t t a2) a1))
|
||||
|
||||
compose f@(Fn [_b] _c) g@(Fn [_a] _b) x@_a =@_c f (g x)
|
||||
compose f g x = f (g x)
|
||||
|
||||
triage leaf stem fork = t (t leaf stem) fork
|
||||
test = triage "Leaf" (_ : "Stem") (_ _ : "Fork")
|
||||
@@ -114,9 +114,9 @@ matchMaybe nothingCase justCase maybe =
|
||||
maybe
|
||||
|
||||
maybe default f m = matchMaybe default f m
|
||||
maybeMap f@(Fn [_a] _b) m@(Maybe _a) =@(Maybe _b) matchMaybe nothing (compose just f) m
|
||||
maybeBind m@(Maybe _a) f@(Fn [_a] (Maybe _b)) =@(Maybe _b) matchMaybe nothing f m
|
||||
maybeOr default@_a m@(Maybe _a) =@_a matchMaybe default id m
|
||||
maybeMap f m = matchMaybe nothing (x : just (f x)) m
|
||||
maybeBind m f = matchMaybe nothing f m
|
||||
maybeOr default m = matchMaybe default id m
|
||||
maybe? = matchMaybe false (_ : true)
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -221,165 +221,3 @@ resultMapErr = (f result :
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- View facts
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
factsFact name provenance view = pair name (pair provenance view)
|
||||
factsChecked = 0
|
||||
factsTrusted = 1
|
||||
factsUnchecked = 2
|
||||
factsField tag value = pair tag value
|
||||
factsRecord tag fields = pair tag fields
|
||||
factsVar id = factsRecord 8 [(factsField 10 id)]
|
||||
factsForall binders body =
|
||||
factsRecord 9 [(factsField 11 binders) (factsField 12 body)]
|
||||
factsFn args result =
|
||||
factsRecord 1 [(factsField 0 args) (factsField 1 result)]
|
||||
factsAny = factsRecord 0 []
|
||||
factsRef symbol = factsRecord 2 [(factsField 2 symbol)]
|
||||
factsBool = factsRef 0
|
||||
factsString = factsRef 1
|
||||
factsByte = factsRef 2
|
||||
factsUnit = factsRef 3
|
||||
factsMaybe elem = factsRecord 4 [(factsField 3 elem)]
|
||||
factsList elem = factsRecord 3 [(factsField 3 elem)]
|
||||
factsPair left right = factsRecord 5 [(factsField 4 left) (factsField 5 right)]
|
||||
factsResult err ok = factsRecord 6 [(factsField 6 err) (factsField 7 ok)]
|
||||
|
||||
viewFacts =
|
||||
[ (factsFact "pair" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsVar 0) (factsList (factsVar 0))]
|
||||
(factsList (factsVar 0)))))
|
||||
(factsFact "nothing" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsMaybe (factsVar 0))))
|
||||
(factsFact "just" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsVar 0)] (factsMaybe (factsVar 0)))))
|
||||
(factsFact "false" factsTrusted factsBool)
|
||||
(factsFact "true" factsTrusted factsBool)
|
||||
(factsFact "if" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [factsBool (factsVar 0) (factsVar 0)] (factsVar 0))))
|
||||
(factsFact "triage" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [factsAny factsAny factsAny factsAny] (factsVar 0))))
|
||||
(factsFact "test" factsTrusted factsString)
|
||||
(factsFact "matchBool" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsVar 0) (factsVar 0) factsBool]
|
||||
(factsVar 0))))
|
||||
(factsFact "lAnd" factsTrusted
|
||||
(factsFn [factsBool factsBool] factsBool))
|
||||
(factsFact "lOr" factsTrusted
|
||||
(factsFn [factsBool factsBool] factsBool))
|
||||
(factsFact "matchPair" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0) (factsVar 1)] (factsVar 2))
|
||||
(factsPair (factsVar 0) (factsVar 1))]
|
||||
(factsVar 2))))
|
||||
(factsFact "fst" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsPair (factsVar 0) (factsVar 1))] (factsVar 0))))
|
||||
(factsFact "snd" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsPair (factsVar 0) (factsVar 1))] (factsVar 1))))
|
||||
(factsFact "not?" factsTrusted
|
||||
(factsFn [factsBool] factsBool))
|
||||
(factsFact "and?" factsTrusted
|
||||
(factsFn [factsBool factsBool] factsBool))
|
||||
(factsFact "or?" factsTrusted
|
||||
(factsFn [factsBool factsBool] factsBool))
|
||||
(factsFact "xor?" factsTrusted
|
||||
(factsFn [factsBool factsBool] factsBool))
|
||||
(factsFact "equal?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsVar 0) (factsVar 0)] factsBool)))
|
||||
(factsFact "succ" factsTrusted
|
||||
(factsFn [factsByte] factsByte))
|
||||
(factsFact "pred" factsTrusted
|
||||
(factsFn [factsByte] factsByte))
|
||||
(factsFact "isZero?" factsTrusted
|
||||
(factsFn [factsByte] factsBool))
|
||||
(factsFact "add" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsByte))
|
||||
(factsFact "sub" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsByte))
|
||||
(factsFact "lte?" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsBool))
|
||||
(factsFact "gte?" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsBool))
|
||||
(factsFact "lt?" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsBool))
|
||||
(factsFact "gt?" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsBool))
|
||||
(factsFact "mul" factsTrusted
|
||||
(factsFn [factsByte factsByte] factsByte))
|
||||
(factsFact "matchMaybe" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsVar 1)
|
||||
(factsFn [(factsVar 0)] (factsVar 1))
|
||||
(factsMaybe (factsVar 0))]
|
||||
(factsVar 1))))
|
||||
(factsFact "maybe" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsVar 1)
|
||||
(factsFn [(factsVar 0)] (factsVar 1))
|
||||
(factsMaybe (factsVar 0))]
|
||||
(factsVar 1))))
|
||||
(factsFact "maybe?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsMaybe (factsVar 0))] factsBool)))
|
||||
(factsFact "ifLazy" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[factsBool
|
||||
(factsFn [factsUnit] (factsVar 0))
|
||||
(factsFn [factsUnit] (factsVar 0))]
|
||||
(factsVar 0))))
|
||||
(factsFact "andLazy?" factsTrusted
|
||||
(factsFn [factsBool (factsFn [factsUnit] factsBool)] factsBool))
|
||||
(factsFact "ok" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsVar 1) factsAny] (factsResult (factsVar 0) (factsVar 1)))))
|
||||
(factsFact "err" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsVar 0) factsAny] (factsResult (factsVar 0) (factsVar 1)))))
|
||||
(factsFact "matchResult" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0) factsAny] (factsVar 2))
|
||||
(factsFn [(factsVar 1) factsAny] (factsVar 2))
|
||||
(factsResult (factsVar 0) (factsVar 1))]
|
||||
(factsVar 2))))
|
||||
(factsFact "resultIsOk" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsResult (factsVar 0) (factsVar 1))] factsBool)))
|
||||
(factsFact "resultIsErr" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsResult (factsVar 0) (factsVar 1))] factsBool)))
|
||||
(factsFact "mapResult" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 1)] (factsVar 2))
|
||||
(factsResult (factsVar 0) (factsVar 1))]
|
||||
(factsResult (factsVar 0) (factsVar 2)))))
|
||||
(factsFact "bindResult" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsResult (factsVar 0) (factsVar 1))
|
||||
(factsFn [(factsVar 1)] (factsResult (factsVar 0) (factsVar 2)))]
|
||||
(factsResult (factsVar 0) (factsVar 2)))))
|
||||
(factsFact "resultOr" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn [(factsVar 1) (factsResult (factsVar 0) (factsVar 1))] (factsVar 1))))
|
||||
(factsFact "resultMapErr" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] (factsVar 2))
|
||||
(factsResult (factsVar 0) (factsVar 1))]
|
||||
(factsResult (factsVar 2) (factsVar 1)))))]
|
||||
|
||||
148
lib/list.tri
148
lib/list.tri
@@ -291,151 +291,3 @@ zipWith_ self f xs ys =
|
||||
ys)
|
||||
xs
|
||||
zipWith = f xs ys : y zipWith_ f xs ys
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- View facts
|
||||
--
|
||||
-- Value-level metadata consumed by View tooling. These facts are ordinary Tree
|
||||
-- Calculus data, not host-side assumptions and not part of the public stdlib
|
||||
-- API exported by module manifests.
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
viewFacts =
|
||||
[(factsFact "matchList" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsVar 1)
|
||||
(factsFn
|
||||
[(factsVar 0) (factsList (factsVar 0))]
|
||||
(factsVar 1))
|
||||
(factsList (factsVar 0))]
|
||||
(factsVar 1))))
|
||||
(factsFact "emptyList?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] factsBool)))
|
||||
(factsFact "tail" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "append" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsList (factsVar 0))
|
||||
(factsList (factsVar 0))]
|
||||
(factsList (factsVar 0)))))
|
||||
(factsFact "lExist?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsVar 0) (factsList (factsVar 0))] factsBool)))
|
||||
(factsFact "map" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] (factsVar 1))
|
||||
(factsList (factsVar 0))]
|
||||
(factsList (factsVar 1)))))
|
||||
(factsFact "filter" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] factsBool)
|
||||
(factsList (factsVar 0))]
|
||||
(factsList (factsVar 0)))))
|
||||
(factsFact "foldl" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 1) (factsVar 0)] (factsVar 1))
|
||||
(factsVar 1)
|
||||
(factsList (factsVar 0))]
|
||||
(factsVar 1))))
|
||||
(factsFact "foldr" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 1) (factsVar 0)] (factsVar 1))
|
||||
(factsVar 1)
|
||||
(factsList (factsVar 0))]
|
||||
(factsVar 1))))
|
||||
(factsFact "length" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] factsByte)))
|
||||
(factsFact "reverse" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "snoc" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsVar 0) (factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "count" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsVar 0) (factsList (factsVar 0))] factsByte)))
|
||||
(factsFact "all?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsFn [(factsVar 0)] factsBool) (factsList (factsVar 0))] factsBool)))
|
||||
(factsFact "any?" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsFn [(factsVar 0)] factsBool) (factsList (factsVar 0))] factsBool)))
|
||||
(factsFact "intersect" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0)) (factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "headMaybe" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] (factsMaybe (factsVar 0)))))
|
||||
(factsFact "lastMaybe" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [(factsList (factsVar 0))] (factsMaybe (factsVar 0)))))
|
||||
(factsFact "nthMaybe" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [factsByte (factsList (factsVar 0))] (factsMaybe (factsVar 0)))))
|
||||
(factsFact "take" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [factsByte (factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "drop" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn [factsByte (factsList (factsVar 0))] (factsList (factsVar 0)))))
|
||||
(factsFact "splitAt" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[factsByte (factsList (factsVar 0))]
|
||||
(factsPair (factsList (factsVar 0)) (factsList (factsVar 0))))))
|
||||
(factsFact "concatMap" factsTrusted
|
||||
(factsForall [0 1]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] (factsList (factsVar 1)))
|
||||
(factsList (factsVar 0))]
|
||||
(factsList (factsVar 1)))))
|
||||
(factsFact "find" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] factsBool)
|
||||
(factsList (factsVar 0))]
|
||||
(factsMaybe (factsVar 0)))))
|
||||
(factsFact "partition" factsTrusted
|
||||
(factsForall [0]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0)] factsBool)
|
||||
(factsList (factsVar 0))]
|
||||
(factsPair (factsList (factsVar 0)) (factsList (factsVar 0))))))
|
||||
(factsFact "strLength" factsTrusted
|
||||
(factsFn [factsString] factsByte))
|
||||
(factsFact "strAppend" factsTrusted
|
||||
(factsFn [factsString factsString] factsString))
|
||||
(factsFact "strEq?" factsTrusted
|
||||
(factsFn [factsString factsString] factsBool))
|
||||
(factsFact "strEmpty?" factsTrusted
|
||||
(factsFn [factsString] factsBool))
|
||||
(factsFact "startsWith?" factsTrusted
|
||||
(factsFn [factsString factsString] factsBool))
|
||||
(factsFact "endsWith?" factsTrusted
|
||||
(factsFn [factsString factsString] factsBool))
|
||||
(factsFact "contains?" factsTrusted
|
||||
(factsFn [factsString factsString] factsBool))
|
||||
(factsFact "lines" factsTrusted
|
||||
(factsFn [factsString] (factsList factsString)))
|
||||
(factsFact "unlines" factsTrusted
|
||||
(factsFn [(factsList factsString)] factsString))
|
||||
(factsFact "words" factsTrusted
|
||||
(factsFn [factsString] (factsList factsString)))
|
||||
(factsFact "unwords" factsTrusted
|
||||
(factsFn [(factsList factsString)] factsString))
|
||||
(factsFact "zipWith" factsTrusted
|
||||
(factsForall [0 1 2]
|
||||
(factsFn
|
||||
[(factsFn [(factsVar 0) (factsVar 1)] (factsVar 2))
|
||||
(factsList (factsVar 0))
|
||||
(factsList (factsVar 1))]
|
||||
(factsList (factsVar 2)))))]
|
||||
|
||||
251
lib/view.tri
251
lib/view.tri
@@ -335,11 +335,12 @@ wellFormedResultView? = (view :
|
||||
wellFormedGuardedView? = (view :
|
||||
fields2? (viewPayload view) viewFieldBase viewFieldGuard)
|
||||
|
||||
wellFormedVarView? = (view :
|
||||
fields1? (viewPayload view) viewFieldVar)
|
||||
-- Tags 8-10 remain reserved so old artifacts decode deterministically, but
|
||||
-- quantified/variable Views are no longer accepted by the checker. They
|
||||
-- implied abstraction and parametricity that raw Tree Calculus cannot enforce.
|
||||
wellFormedVarView? = (_ : false)
|
||||
|
||||
wellFormedQuantifiedView? = (view :
|
||||
fields2? (viewPayload view) viewFieldBinders viewFieldBody)
|
||||
wellFormedQuantifiedView? = (_ : false)
|
||||
|
||||
wellFormedView_ self view =
|
||||
lazyBool
|
||||
@@ -513,28 +514,6 @@ hasView? = (symbol view env :
|
||||
(viewSet : viewSetHas? view viewSet)
|
||||
(lookupViews symbol env))
|
||||
|
||||
viewSetHasCompatible_ self namespace expected viewSet =
|
||||
lazyList
|
||||
(_ : false)
|
||||
(fact rest :
|
||||
lazyMaybe
|
||||
(_ : self namespace expected rest)
|
||||
(_ : true)
|
||||
(matchView expected (instantiateView namespace (viewFactView fact)) t))
|
||||
viewSet
|
||||
|
||||
viewSetHasCompatible? = (namespace expected viewSet :
|
||||
lazyBool
|
||||
(_ : true)
|
||||
(_ : y viewSetHasCompatible_ namespace expected viewSet)
|
||||
(anyView? expected))
|
||||
|
||||
hasCompatibleView? = (symbol view env :
|
||||
lazyMaybe
|
||||
(_ : anyView? view)
|
||||
(viewSet : viewSetHasCompatible? symbol view viewSet)
|
||||
(lookupViews symbol env))
|
||||
|
||||
addViewToSet = (view evidence viewSet :
|
||||
lazyBool
|
||||
(_ : viewSet)
|
||||
@@ -557,44 +536,19 @@ extendEnv_ self symbol view evidence env =
|
||||
extendEnv = (symbol view evidence env :
|
||||
y extendEnv_ symbol view evidence env)
|
||||
|
||||
instantiateVarId = (namespace localId :
|
||||
pair namespace localId)
|
||||
|
||||
instantiateBinders_ self namespace binders subst =
|
||||
lazyList
|
||||
(_ : subst)
|
||||
(binder rest :
|
||||
self namespace rest (pair (pair binder (viewVar (instantiateVarId namespace binder))) subst))
|
||||
binders
|
||||
|
||||
instantiateBinders = (namespace binders subst :
|
||||
y instantiateBinders_ namespace binders subst)
|
||||
|
||||
instantiateView = (namespace view :
|
||||
lazyBool
|
||||
(_ : substituteView (instantiateBinders namespace (viewBinderNames view) t) (viewQuantifiedBody view))
|
||||
(_ : view)
|
||||
(forallView? view))
|
||||
|
||||
viewAsFn = (namespace view :
|
||||
let instantiated = instantiateView namespace view in
|
||||
lazyBool
|
||||
(_ : just instantiated)
|
||||
(_ : nothing)
|
||||
(fnView? instantiated))
|
||||
|
||||
findFnView_ self namespace viewSet =
|
||||
findFnView_ self viewSet =
|
||||
lazyList
|
||||
(_ : nothing)
|
||||
(fact rest :
|
||||
lazyMaybe
|
||||
let view = viewFactView fact in
|
||||
lazyBool
|
||||
(_ : just view)
|
||||
(_ : self rest)
|
||||
(fnView : just fnView)
|
||||
(viewAsFn namespace (viewFactView fact)))
|
||||
(fnView? view))
|
||||
viewSet
|
||||
|
||||
findFnView = (namespace viewSet :
|
||||
y findFnView_ namespace viewSet)
|
||||
findFnView = (viewSet :
|
||||
y findFnView_ viewSet)
|
||||
|
||||
firstKnownView = (viewSet :
|
||||
lazyList
|
||||
@@ -607,157 +561,6 @@ actualViewFor = (symbol env :
|
||||
(_ : viewAny)
|
||||
(viewSet : firstKnownView viewSet)
|
||||
(lookupViews symbol env))
|
||||
|
||||
substLookup_ self name subst =
|
||||
lazyList
|
||||
(_ : nothing)
|
||||
(entry rest :
|
||||
lazyBool
|
||||
(_ : just (snd entry))
|
||||
(_ : self name rest)
|
||||
(equal? name (fst entry)))
|
||||
subst
|
||||
|
||||
substLookup = (name subst : y substLookup_ name subst)
|
||||
|
||||
substBind = (name actual subst :
|
||||
lazyBool
|
||||
(_ : just subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : just subst)
|
||||
(_ :
|
||||
lazyMaybe
|
||||
(_ : just (pair (pair name actual) subst))
|
||||
(existing :
|
||||
lazyBool
|
||||
(_ : just subst)
|
||||
(_ : nothing)
|
||||
(equal? existing actual))
|
||||
(substLookup name subst))
|
||||
(varView? actual))
|
||||
(equal? actual (viewVar name)))
|
||||
|
||||
substituteView_ self subst view =
|
||||
lazyBool
|
||||
(_ :
|
||||
lazyMaybe
|
||||
(_ : view)
|
||||
(bound : self subst bound)
|
||||
(substLookup (viewVarName view) subst))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewFn (y substituteViews_ self subst (fnArgs view)) (self subst (fnResult view)))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewList (self subst (field0 (viewPayload view))))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewMaybe (self subst (field0 (viewPayload view))))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewPair (self subst (field0 (viewPayload view))) (self subst (field1 (viewPayload view))))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewResult (self subst (field0 (viewPayload view))) (self subst (field1 (viewPayload view))))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : viewGuarded (self subst (guardedViewBase view)) (guardedViewGuard view))
|
||||
(_ : view)
|
||||
(guardedView? view))
|
||||
(resultView? view))
|
||||
(pairView? view))
|
||||
(maybeView? view))
|
||||
(listView? view))
|
||||
(fnView? view))
|
||||
(varView? view)
|
||||
|
||||
substituteViews_ self viewSelf subst views =
|
||||
lazyList
|
||||
(_ : t)
|
||||
(view rest : pair (viewSelf subst view) (self viewSelf subst rest))
|
||||
views
|
||||
|
||||
substituteView = (subst view : y substituteView_ subst view)
|
||||
|
||||
matchViewList_ self matchSelf expected actual subst =
|
||||
lazyList
|
||||
(_ :
|
||||
lazyList
|
||||
(_ : just subst)
|
||||
(_ _ : nothing)
|
||||
actual)
|
||||
(expectedHead expectedRest :
|
||||
lazyList
|
||||
(_ : nothing)
|
||||
(actualHead actualRest :
|
||||
lazyMaybe
|
||||
(_ : nothing)
|
||||
(nextSubst : self matchSelf expectedRest actualRest nextSubst)
|
||||
(matchSelf expectedHead actualHead subst))
|
||||
actual)
|
||||
expected
|
||||
|
||||
matchView_ self expected actual subst =
|
||||
lazyBool
|
||||
(_ : just subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : substBind (viewVarName expected) actual subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : substBind (viewVarName actual) expected subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : just subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ :
|
||||
lazyMaybe
|
||||
(_ : nothing)
|
||||
(argSubst : self (fnResult expected) (fnResult actual) argSubst)
|
||||
(y matchViewList_ self (fnArgs expected) (fnArgs actual) subst))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : self (field0 (viewPayload expected)) (field0 (viewPayload actual)) subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : self (field0 (viewPayload expected)) (field0 (viewPayload actual)) subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ :
|
||||
lazyMaybe
|
||||
(_ : nothing)
|
||||
(leftSubst : self (field1 (viewPayload expected)) (field1 (viewPayload actual)) leftSubst)
|
||||
(self (field0 (viewPayload expected)) (field0 (viewPayload actual)) subst))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ :
|
||||
lazyMaybe
|
||||
(_ : nothing)
|
||||
(errSubst : self (field1 (viewPayload expected)) (field1 (viewPayload actual)) errSubst)
|
||||
(self (field0 (viewPayload expected)) (field0 (viewPayload actual)) subst))
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : self (guardedViewBase expected) actual subst)
|
||||
(_ :
|
||||
lazyBool
|
||||
(_ : self expected (guardedViewBase actual) subst)
|
||||
(_ : nothing)
|
||||
(guardedView? actual))
|
||||
(guardedView? expected))
|
||||
(and? (resultView? expected) (resultView? actual)))
|
||||
(and? (pairView? expected) (pairView? actual)))
|
||||
(and? (maybeView? expected) (maybeView? actual)))
|
||||
(and? (listView? expected) (listView? actual)))
|
||||
(and? (fnView? expected) (fnView? actual)))
|
||||
(equal? expected actual))
|
||||
(varView? actual))
|
||||
(varView? expected))
|
||||
(anyView? expected)
|
||||
|
||||
matchView = (expected actual subst : y matchView_ expected actual subst)
|
||||
|
||||
checkerErr = (tag fields env : err (diagnostic tag fields) env)
|
||||
checkerOk = (env : ok env t)
|
||||
|
||||
@@ -789,28 +592,16 @@ checkApplicationSymbols = (policy argSymbol outSymbol env fnView :
|
||||
lazyList
|
||||
(_ : checkerErr errorTagZeroArityFunction t env)
|
||||
(argView restArgs :
|
||||
let actualView = instantiateView argSymbol (actualViewFor argSymbol env) in
|
||||
lazyMaybe
|
||||
let resultView = fnResidual restArgs (fnResult fnView) in
|
||||
lazyBool
|
||||
(_ : checkerOk (extendEnv outSymbol resultView evidenceTagInferred env))
|
||||
(_ :
|
||||
lazyResult
|
||||
(diag envAtError : err diag envAtError)
|
||||
(nextEnv _ : checkerOk (extendEnv outSymbol (fnResidual restArgs (fnResult fnView)) evidenceTagInferred nextEnv))
|
||||
(nextEnv _ : checkerOk (extendEnv outSymbol resultView evidenceTagInferred nextEnv))
|
||||
(missingArgumentOrGuardedBase policy argSymbol argView env))
|
||||
(subst :
|
||||
let nextEnv =
|
||||
lazyBool
|
||||
(_ : extendEnv argSymbol argView evidenceTagRequired env)
|
||||
(_ : env)
|
||||
(guardedView? argView) in
|
||||
checkerOk
|
||||
(extendEnv
|
||||
outSymbol
|
||||
(substituteView subst (fnResidual restArgs (fnResult fnView)))
|
||||
evidenceTagInferred
|
||||
nextEnv))
|
||||
(matchView argView actualView t))
|
||||
(hasView? argSymbol argView env))
|
||||
(fnArgs fnView))
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- View-tree checker artifact
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -964,7 +755,7 @@ checkTypedRequireNode = (policy node env :
|
||||
(hasView? symbol (guardedViewBase view) env))
|
||||
(_ : missingRequiredView policy symbol view env)
|
||||
(guardedView? view))
|
||||
(hasCompatibleView? symbol view env))
|
||||
(hasView? symbol view env))
|
||||
|
||||
missingArgumentOrGuardedBase = (policy symbol view env :
|
||||
lazyBool
|
||||
@@ -983,7 +774,7 @@ checkTypedApplyNode = (policy node env :
|
||||
lazyMaybe
|
||||
(_ : checkerOk env)
|
||||
(fnView : checkApplicationSymbols policy (typedApplyArg node) (typedNodeSymbol node) env fnView)
|
||||
(findFnView (typedApplyCallee node) calleeViews))
|
||||
(findFnView calleeViews))
|
||||
(lookupViews (typedApplyCallee node) env))
|
||||
|
||||
checkTypedNode = (policy node env :
|
||||
@@ -1762,8 +1553,8 @@ viewContractSelfTests = [
|
||||
(viewContractProbe (wellFormedView? (viewPair viewBool viewString)))
|
||||
(viewContractProbe (wellFormedView? (viewResult viewString viewBool)))
|
||||
(viewContractProbe (wellFormedView? (viewGuarded viewString (x : x))))
|
||||
(viewContractProbe (wellFormedView? (viewVar 0)))
|
||||
(viewContractProbe (wellFormedView? (viewForall [(0)] (viewFn [(viewVar 0)] (viewVar 0)))))
|
||||
(viewContractProbe (not? (wellFormedView? (viewVar 0))))
|
||||
(viewContractProbe (not? (wellFormedView? (viewForall [(0)] (viewFn [(viewVar 0)] (viewVar 0))))))
|
||||
(viewContractProbe (equal? (renderView viewBool) "Bool"))
|
||||
(viewContractProbe (equal? (renderView (viewList viewBool)) "List Bool"))
|
||||
(viewContractProbe (equal? (renderView (viewMaybe viewString)) "Maybe String"))
|
||||
|
||||
Reference in New Issue
Block a user