Skip to content

Commit

Permalink
Remove List.drop and use List.skip
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed May 29, 2020
1 parent 3d19992 commit 2077b18
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/absil/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ module List =
| [] -> None
| h :: t -> if f h then Some (h, n) else findi (n+1) f t

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
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ and ReportNoCandidatesError (csenv: ConstraintSolverEnv) (nUnnamedCallerArgs, nN
else
if nReqd > nActual then
let diff = nReqd - nActual
let missingArgs = List.drop nReqd cmeth.AllUnnamedCalledArgs
let missingArgs = List.skip nReqd cmeth.AllUnnamedCalledArgs
match NamesOfCalledArgs missingArgs with
| [] ->
if nActual = 0 then
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/DetupleArgs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ let mkTransform g (f: Val) m tps x1Ntys rty (callPattern, tyfringes: (TType list
| _ -> Some(ValReprInfo (ValReprInfo.InferTyparInfo tps, List.collect ValReprInfoForTS callPattern, ValReprInfo.unnamedRetVal))
(* type(transformedVal) tyfringes types replace initial arg types of f *)
let tys1r = List.collect fst tyfringes (* types for collapsed initial r args *)
let tysrN = List.drop tyfringes.Length x1Ntys (* types for remaining args *)
let tysrN = List.skip tyfringes.Length x1Ntys (* types for remaining args *)
let argtys = tys1r @ tysrN
let fCty = mkLambdaTy tps argtys rty
let transformedVal =
Expand Down Expand Up @@ -784,7 +784,7 @@ let passBind penv (TBind(fOrig, repr, letSeqPtOpt) as bind) =
let transformedFormals = trans.transformedFormals
let p = transformedFormals.Length
if (vss.Length < p) then internalError "passBinds: |vss|<p - detuple pass"
let xqNs = List.drop p vss
let xqNs = List.skip p vss
let x1ps = List.truncate p vss
let y1Ps = List.concat (List.map2 transFormal transformedFormals x1ps)
let formals = y1Ps @ xqNs
Expand Down
3 changes: 2 additions & 1 deletion src/fsharp/FSharp.Core/list.fs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,11 @@ namespace Microsoft.FSharp.Collections
let skip count list =
if count <= 0 then list else
let rec loop i lst =
if i = 0 then lst else
match lst with
| _ when i = 0 -> lst
| _ :: t -> loop (i-1) t
| [] -> invalidArgOutOfRange "count" count "distance past the list" i

loop count list

[<CompiledName("SkipWhile")>]
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5986,7 +5986,7 @@ and GenMethodForBinding
match v.MemberInfo with
| Some memberInfo when not v.IsExtensionMember ->

let ilMethTypars = ilTypars |> List.drop mspec.DeclaringType.GenericArgs.Length
let ilMethTypars = ilTypars |> List.skip mspec.DeclaringType.GenericArgs.Length
if memberInfo.MemberFlags.MemberKind = MemberKind.Constructor then
assert (isNil ilMethTypars)
let mdef = mkILCtor (access, ilParams, ilMethodBody)
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ let LookupTypeNameInEntityMaybeHaveArity (amap, m, ad, nm, staticResInfo: TypeNa
/// Handle the .NET/C# business where nested generic types implicitly accumulate the type parameters
/// from their enclosing types.
let MakeNestedType (ncenv: NameResolver) (tinst: TType list) m (tcrefNested: TyconRef) =
let tps = List.drop tinst.Length (tcrefNested.Typars m)
let tps = List.skip tinst.Length (tcrefNested.Typars m)
let tinstNested = ncenv.InstantiationGenerator m tps
mkAppTy tcrefNested (tinst @ tinstNested)

Expand Down
10 changes: 6 additions & 4 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ let AdjustAndForgetUsesOfRecValue cenv (vrefTgt: ValRef) (valScheme: ValScheme)
errorR(Error(FSComp.SR.tcUnexpectedExprAtRecInfPoint(), m))
NormalValUse, []

let ityargs = generalizeTypars (List.drop (List.length tyargs0) generalizedTypars)
let ityargs = generalizeTypars (List.skip (List.length tyargs0) generalizedTypars)
primMkApp (Expr.Val (vrefTgt, vrefFlags, m), fty) (tyargs0 @ ityargs) [] m
fixupPoint.Value <- fixedUpExpr)

Expand Down Expand Up @@ -5070,12 +5070,14 @@ and TcTypeApp cenv newOk checkCxs occ env tpenv m tcref pathTypeArgs (synArgTys:
// If we're not checking constraints, i.e. when we first assert the super/interfaces of a type definition, then just
// clear the constraint lists of the freshly generated type variables. A little ugly but fairly localized.
if checkCxs = NoCheckCxs then tps |> List.iter (fun tp -> tp.SetConstraints [])
if tinst.Length <> pathTypeArgs.Length + synArgTys.Length then
error (TyconBadArgs(env.DisplayEnv, tcref, pathTypeArgs.Length + synArgTys.Length, m))
let synArgTysLength = synArgTys.Length
let pathTypeArgsLength = pathTypeArgs.Length
if tinst.Length <> pathTypeArgsLength + synArgTysLength then
error (TyconBadArgs(env.DisplayEnv, tcref, pathTypeArgsLength + synArgTysLength, m))

let argTys, tpenv =
// Get the suffix of typars
let tpsForArgs = List.drop (tps.Length - synArgTys.Length) tps
let tpsForArgs = List.skip (tps.Length - synArgTysLength) tps
let kindsForArgs = tpsForArgs |> List.map (fun tp -> tp.Kind)
TcTypesOrMeasures (Some kindsForArgs) cenv newOk checkCxs occ env tpenv synArgTys m

Expand Down

0 comments on commit 2077b18

Please sign in to comment.