diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 1d873017d08..dab61033a3f 100644 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -279,22 +279,11 @@ module List = | [] -> None | h::t -> if f h then Some (h,n) else findi (n+1) f t - - let take n l = - if n = List.length l then l else - let rec loop acc n l = - match l with - | [] -> List.rev acc - | x::xs -> if n<=0 then List.rev acc else loop (x::acc) (n-1) xs - - loop [] n l - let rec drop n l = match l with | [] -> [] | _::xs -> if n=0 then l else drop (n-1) xs - let splitChoose select l = let rec ch acc1 acc2 l = match l with diff --git a/src/fsharp/DetupleArgs.fs b/src/fsharp/DetupleArgs.fs index 2dfc01e1cc7..b4db62a9b3f 100644 --- a/src/fsharp/DetupleArgs.fs +++ b/src/fsharp/DetupleArgs.fs @@ -511,7 +511,7 @@ let zipCallPatternArgTys m g (callPattern : TupleStructure list) (vss : Val list let tys = List.collect snd tstys // link fringes tss, tys - let vss = List.take callPattern.Length vss // drop excessive tys if callPattern shorter + let vss = List.truncate callPattern.Length vss // drop excessive tys if callPattern shorter let tstys = List.map2 (fun ts vs -> let ts, tyfringe = zipTSTyp ts (typeOfLambdaArg m vs) in ts, (tyfringe, vs)) callPattern vss List.unzip tstys @@ -561,16 +561,16 @@ let decideTransform g z v callPatterns (m, tps, vss:Val list list, rty) = (* NOTE: 'a in arg types may have been instanced at different tuples... *) (* commonCallPattern has to handle those cases. *) let callPattern = commonCallPattern callPatterns // common CallPattern - let callPattern = List.take vss.Length callPattern // restricted to max nArgs + let callPattern = List.truncate vss.Length callPattern // restricted to max nArgs // Get formal callPattern by defn usage of formals let formalCallPattern = decideFormalSuggestedCP g z tys vss - let callPattern = List.take callPattern.Length formalCallPattern + let callPattern = List.truncate callPattern.Length formalCallPattern // Zip with information about known args let callPattern, tyfringes = zipCallPatternArgTys m g callPattern vss // Drop trivial tail AND let callPattern = minimalCallPattern callPattern // Shorten tyfringes (zippable) - let tyfringes = List.take callPattern.Length tyfringes + let tyfringes = List.truncate callPattern.Length tyfringes if isTrivialCP callPattern then None // no transform else @@ -790,7 +790,7 @@ let passBind penv (TBind(fOrig, repr, letSeqPtOpt) as bind) = let p = transformedFormals.Length if (vss.Length < p) then internalError "passBinds: |vss|
wholem | _ -> - let ids = List.take (max 0 (lid.Length - rest.Length)) lid + let ids = List.truncate (max 0 (lid.Length - rest.Length)) lid match ids with | [] -> wholem | _ -> rangeOfLid ids diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index a57a0178c1e..9fd1e17f42c 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -170,7 +170,7 @@ module private PrintIL = match System.Int32.TryParse(rightMost, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture) with | true, n -> n | false, _ -> 0 // looks like it's non-generic - ilTyparSubst |> List.rev |> List.take numParms |> List.rev + ilTyparSubst |> List.rev |> List.truncate numParms |> List.rev let rec layoutILType (denv: DisplayEnv) (ilTyparSubst: layout list) (typ : ILType) : layout = match typ with diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 238c84ce31d..603fc2804c2 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -2590,7 +2590,7 @@ and OptimizeApplication cenv env (f0, f0ty, tyargs, args, m) = let nDetupArgsL = detupArgsL.Length let nShapes = min nargs nDetupArgsL let detupArgsShapesL = - List.take nShapes detupArgsL + List.truncate nShapes detupArgsL |> List.map (fun detupArgs -> match detupArgs with | [] | [_] -> UnknownValue diff --git a/src/fsharp/QuotationTranslator.fs b/src/fsharp/QuotationTranslator.fs index 647bd5f8781..f8d327a7b47 100644 --- a/src/fsharp/QuotationTranslator.fs +++ b/src/fsharp/QuotationTranslator.fs @@ -261,7 +261,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. // Check to see if there aren't enough arguments or if there is a tuple-arity mismatch // If so, adjust and try again if curriedArgs.Length < curriedArgInfos.Length || - ((List.take curriedArgInfos.Length curriedArgs,curriedArgInfos) ||> List.exists2 (fun arg argInfo -> + ((List.truncate curriedArgInfos.Length curriedArgs,curriedArgInfos) ||> List.exists2 (fun arg argInfo -> (argInfo.Length > (tryDestRefTupleExpr arg).Length))) then if verboseCReflect then diff --git a/src/fsharp/SignatureConformance.fs b/src/fsharp/SignatureConformance.fs index f0efca64fe0..429a78a0d69 100644 --- a/src/fsharp/SignatureConformance.fs +++ b/src/fsharp/SignatureConformance.fs @@ -239,8 +239,8 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = elif not (sigArgInfos.Length <= implArgInfos.Length && List.forall2 (fun x y -> List.length x <= List.length y) sigArgInfos (List.truncate sigArgInfos.Length implArgInfos)) then err(fun(x, y, z) -> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, string sigArgInfos.Length, id.idText, id.idText)) else - let implArgInfos = implArgInfos |> List.take sigArgInfos.Length - let implArgInfos = (implArgInfos, sigArgInfos) ||> List.map2 (fun l1 l2 -> l1 |> List.take l2.Length) + let implArgInfos = implArgInfos |> List.truncate sigArgInfos.Length + let implArgInfos = (implArgInfos, sigArgInfos) ||> List.map2 (fun l1 l2 -> l1 |> List.truncate l2.Length) // Propagate some information signature to implementation. // Check the attributes on each argument, and update the ValReprInfo for diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index aaa9981c771..c0c0bc8e04c 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -4991,7 +4991,7 @@ and TcNestedTypeApplication cenv newOk checkCxs occ env tpenv mWholeTypeApp typ if not (isAppTy cenv.g typ) then error(Error(FSComp.SR.tcTypeHasNoNestedTypes(), mWholeTypeApp)) match typ with | TType_app(tcref, tinst) -> - let pathTypeArgs = List.take (max (tinst.Length - tcref.Typars(mWholeTypeApp).Length) 0) tinst + let pathTypeArgs = List.truncate (max (tinst.Length - tcref.Typars(mWholeTypeApp).Length) 0) tinst TcTypeApp cenv newOk checkCxs occ env tpenv mWholeTypeApp tcref pathTypeArgs tyargs | _ -> error(InternalError("TcNestedTypeApplication: expected type application", mWholeTypeApp)) @@ -5273,7 +5273,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p let args = match args with SynConstructorArgs.Pats args -> args | _ -> failwith "impossible: active patterns can be used only with SynConstructorArgs.Pats" let e = if dotms.Length = longId.Length then - let e = SynExpr.LongIdent(false, LongIdentWithDots(longId, List.take (dotms.Length - 1) dotms), None, m) + let e = SynExpr.LongIdent(false, LongIdentWithDots(longId, List.truncate (dotms.Length - 1) dotms), None, m) SynExpr.DiscardAfterMissingQualificationAfterDot(e, unionRanges e.Range (List.last dotms)) else SynExpr.LongIdent(false, lidwd, None, m) List.fold (fun f x -> mkSynApp1 f (convSynPatToSynExpr x) m) e args @@ -13690,7 +13690,7 @@ module MutRecBindingChecking = let thisValOpt = GetInstanceMemberThisVariable (v, x) // Members have at least as many type parameters as the enclosing class. Just grab the type variables for the type. - let thisTyInst = List.map mkTyparTy (List.take (tcref.Typars(v.Range).Length) v.Typars) + let thisTyInst = List.map mkTyparTy (List.truncate (tcref.Typars(v.Range).Length) v.Typars) let x = localReps.FixupIncrClassExprPhase2C cenv thisValOpt safeStaticInitInfo thisTyInst x diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index aa0391105c7..b3c50cfbbb6 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -176,7 +176,7 @@ type LongIdentWithDots = | LongIdentWithDots([],_) -> failwith "rangeOfLidwd" | LongIdentWithDots([id],_) -> id.idRange | LongIdentWithDots(h::t,dotms) -> - let nonExtraDots = if dotms.Length = t.Length then dotms else List.take t.Length dotms + let nonExtraDots = if dotms.Length = t.Length then dotms else List.truncate t.Length dotms unionRanges h.idRange (List.last t).idRange |> unionRanges (List.last nonExtraDots) //------------------------------------------------------------------------ diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs index ab36bd0ca4e..11bf33dec35 100644 --- a/src/fsharp/symbols/Exprs.fs +++ b/src/fsharp/symbols/Exprs.fs @@ -422,7 +422,7 @@ module FSharpExprConvert = // Check to see if there aren't enough arguments or if there is a tuple-arity mismatch // If so, adjust and try again if curriedArgs.Length < curriedArgInfos.Length || - ((List.take curriedArgInfos.Length curriedArgs, curriedArgInfos) ||> List.exists2 (fun arg argInfo -> (argInfo.Length > (tryDestRefTupleExpr arg).Length))) then + ((List.truncate curriedArgInfos.Length curriedArgs, curriedArgInfos) ||> List.exists2 (fun arg argInfo -> (argInfo.Length > (tryDestRefTupleExpr arg).Length))) then // Too few arguments or incorrect tupling? Convert to a lambda and beta-reduce the // partially applied arguments to 'let' bindings