This commit is contained in:
Erik Svedäng 2020-05-21 11:18:20 +02:00
commit 850c1938ed
3 changed files with 15 additions and 7 deletions

View File

@ -11,10 +11,10 @@
result))
(doc iterate-until "Like `iterate`, but f is applied repeatedly until the predicate `pred` is true.")
(sig iterate-until (Fn [a, (Ref (Fn [b] b c) d), (Ref (Fn [b] Bool c) e), b] b))
(sig iterate-until (Fn [(Ref (Fn [b] b c) d), (Ref (Fn [b] Bool c) e), b] b))
(defn iterate-until [f pred start]
(let-do [result start]
(while (not (~pred &result))
(while (not (~pred result))
(set! result (~f result)))
result))

View File

@ -493,8 +493,13 @@ specialCommandWhile ctx cond body = do
Left e -> return (newCtx, Left e)
getSigFromDefnOrDef :: Context -> Env -> FilePathPrintLength -> XObj -> (Either EvalError (Maybe (Ty, XObj)))
getSigFromDefnOrDef ctx globalEnv fppl xobj =
let metaData = existingMeta globalEnv xobj
getSigFromDefnOrDef ctx globalEnv fppl xobj@(XObj _ i t) =
let pathStrings = contextPath ctx
path = (getPath xobj)
fullPath = case path of
(SymPath [] n) -> consPath pathStrings path
(SymPath quals n) -> path
metaData = existingMeta globalEnv (XObj (Sym fullPath Symbol) i t)
in case Map.lookup "sig" (getMeta metaData) of
Just foundSignature ->
case xobjToTy foundSignature of

View File

@ -27,9 +27,12 @@ genConstraints globalEnv root rootSig = fmap sort (gen root)
bodyConstr = Constraint retTy bodyType xobj body xobj OrdDefnBody
argConstrs = zipWith3 (\a b aObj -> Constraint a b aObj xobj xobj OrdArg) (List.map forceTy args) argTys args
-- The constraint generated by type signatures, like (sig foo (Fn ...)):
sigConstr = case rootSig of
Just (rootSigTy, rootSigXObj) -> [Constraint rootSigTy xobjType rootSigXObj xobj xobj OrdSignatureAnnotation]
Nothing -> []
-- This constraint is ignored for any xobj != rootxobj (ie. (fn) let bindings)
sigConstr = if root == xobj
then case rootSig of
Just (rootSigTy, rootSigXObj) -> [Constraint rootSigTy xobjType rootSigXObj xobj xobj OrdSignatureAnnotation]
Nothing -> []
else []
captureList :: [XObj]
captureList = Set.toList captures
capturesConstrs = mapMaybe id