mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-04 01:25:04 +03:00
Merge branch 'master' of https://github.com/carp-lang/Carp
This commit is contained in:
commit
850c1938ed
@ -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))
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user