diff --git a/src/Fable.Build/GithubRelease.fs b/src/Fable.Build/GithubRelease.fs index fa8c293f8b..450c17bb7e 100644 --- a/src/Fable.Build/GithubRelease.fs +++ b/src/Fable.Build/GithubRelease.fs @@ -71,7 +71,7 @@ let handle (args: string list) = let githubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN_FABLE_ORG") - if githubToken = null then + if isNull githubToken then failwith "Missing GITHUB_TOKEN_FABLE_ORG environment variable" let versionInfo = Changelog.getLastVersion Changelog.fableCLi diff --git a/src/Fable.Build/Publish.fs b/src/Fable.Build/Publish.fs index a189e483a5..f8bee1d658 100644 --- a/src/Fable.Build/Publish.fs +++ b/src/Fable.Build/Publish.fs @@ -68,7 +68,7 @@ let private publishNuget (fsprojDir: string) = let nugetKey = Environment.GetEnvironmentVariable("FABLE_NUGET_KEY") - if nugetKey = null then + if isNull nugetKey then failwithf $"Missing FABLE_NUGET_KEY environment variable" if Fsproj.needPublishing fsprojContent lastVersion then diff --git a/src/Fable.Build/Utils/ChangelogParser.fs b/src/Fable.Build/Utils/ChangelogParser.fs index 1abc7d84b3..950b59bf1f 100644 --- a/src/Fable.Build/Utils/ChangelogParser.fs +++ b/src/Fable.Build/Utils/ChangelogParser.fs @@ -71,30 +71,35 @@ module Types = [] module Lexer = + [] let private (|Match|_|) pattern input = let m = Regex.Match(input, pattern) if m.Success then - Some m + ValueSome m else - None + ValueNone + [] let private (|Title|_|) (input: string) = match input with - | Match "^# ?[^#]" _ -> input.Substring(1).Trim() |> Some - | _ -> None + | Match "^# ?[^#]" _ -> input.Substring(1).Trim() |> ValueSome + | _ -> ValueNone + [] let private (|Semver|_|) (input: string) = match input with | Match "\\[?v?([\\w\\d.-]+\\.[\\w\\d.-]+[a-zA-Z0-9])\\]?" m -> - Some m.Groups.[1].Value - | _ -> None + ValueSome m.Groups.[1].Value + | _ -> ValueNone + [] let private (|Date|_|) (input: string) = match input with - | Match "(\\d{4}-\\d{2}-\\d{2})" m -> Some m.Groups.[0].Value - | _ -> None + | Match "(\\d{4}-\\d{2}-\\d{2})" m -> ValueSome m.Groups.[0].Value + | _ -> ValueNone + [] let private (|Version|_|) (input: string) = match input with | Match "^##? ?[^#]" _ -> @@ -110,24 +115,27 @@ module Lexer = let title = input.Substring(2).Trim() - Some(title, version, date) + ValueSome(title, version, date) - | _ -> None + | _ -> ValueNone + [] let private (|SubSection|_|) (input: string) = match input with - | Match "^### ?[^#]" _ -> input.Substring(3).Trim() |> Some - | _ -> None + | Match "^### ?[^#]" _ -> input.Substring(3).Trim() |> ValueSome + | _ -> ValueNone + [] let private (|SubSubSection|_|) (input: string) = match input with - | Match "^#### ?[^#]" _ -> input.Substring(4).Trim() |> Some - | _ -> None + | Match "^#### ?[^#]" _ -> input.Substring(4).Trim() |> ValueSome + | _ -> ValueNone + [] let private (|ListItem|_|) (input: string) = match input with - | Match "^[*-]" _ -> input.Substring(1).Trim() |> Some - | _ -> None + | Match "^[*-]" _ -> input.Substring(1).Trim() |> ValueSome + | _ -> ValueNone let toSymbols (lines: string list) = lines diff --git a/src/Fable.Cli/FileWatchers.fs b/src/Fable.Cli/FileWatchers.fs index a212169086..ae951624b9 100644 --- a/src/Fable.Cli/FileWatchers.fs +++ b/src/Fable.Cli/FileWatchers.fs @@ -118,10 +118,9 @@ type PollingFileWatcher(watchedDirectoryPath, ignoredDirectoryNameRegexes) = (fun f -> let fullFilePath = f.FullName - if not <| knownEntities.ContainsKey(fullFilePath) then - recordChange f // New file - else - let fileMeta = knownEntities.[fullFilePath] + match knownEntities.TryGetValue fullFilePath with + | false, _ -> recordChange f // New file + | true, fileMeta -> try if diff --git a/src/Fable.Transforms/FSharp2Fable.fs b/src/Fable.Transforms/FSharp2Fable.fs index 5643ddea9f..a0810cd49f 100644 --- a/src/Fable.Transforms/FSharp2Fable.fs +++ b/src/Fable.Transforms/FSharp2Fable.fs @@ -3234,9 +3234,9 @@ type FableCompiler(com: Compiler) = let onlyOnceWarnings = HashSet() member _.ReplaceAttachedMembers(entityFullName, f) = - if attachedMembers.ContainsKey(entityFullName) then - attachedMembers[entityFullName] <- f attachedMembers[entityFullName] - else + match attachedMembers.TryGetValue entityFullName with + | true, members -> attachedMembers[entityFullName] <- f members + | false, _ -> let members = {| NonMangledNames = HashSet() diff --git a/src/Fable.Transforms/Php/Fable2Php.fs b/src/Fable.Transforms/Php/Fable2Php.fs index 118ebbfe8b..a6ffc03366 100644 --- a/src/Fable.Transforms/Php/Fable2Php.fs +++ b/src/Fable.Transforms/Php/Fable2Php.fs @@ -1920,7 +1920,7 @@ and findCasesNames evalExpr tree = and hasGroupedCases indices tree = match tree with - | Fable.IfThenElse(Fable.Test(_, _, _), + | Fable.IfThenElse(Fable.Test(_), Fable.DecisionTreeSuccess(index, _, _), elseExpr, _) -> @@ -1933,18 +1933,18 @@ and hasGroupedCases indices tree = true else false - | Fable.IfThenElse(Fable.Test(_, _, _), _, _, _) -> false + | Fable.IfThenElse(Fable.Test(_), _, _, _) -> false | _ -> failwithf "Invalid Condition AST" and getCases cases tree = match tree with - | Fable.IfThenElse(Fable.Test(_, _, _), + | Fable.IfThenElse(Fable.Test(_), Fable.DecisionTreeSuccess(index, boundValues, _), elseExpr, _) -> getCases (Map.add index boundValues cases) elseExpr | Fable.DecisionTreeSuccess(index, boundValues, _) -> Map.add index boundValues cases - | Fable.IfThenElse(Fable.Test(_, _, _), _, _, _) -> cases + | Fable.IfThenElse(Fable.Test(_), _, _, _) -> cases | _ -> failwithf "Invalid Condition AST" diff --git a/src/Fable.Transforms/Python/Replacements.fs b/src/Fable.Transforms/Python/Replacements.fs index 0e3c81cac2..e5ec9aea43 100644 --- a/src/Fable.Transforms/Python/Replacements.fs +++ b/src/Fable.Transforms/Python/Replacements.fs @@ -2193,7 +2193,7 @@ let operators ?loc = r ) |> Some - | ExprType(Number(_, _)) :: _ -> + | ExprType(Number(_)) :: _ -> Helper.LibCall( com, "long", diff --git a/src/Fable.Transforms/Replacements.fs b/src/Fable.Transforms/Replacements.fs index 3c5e584ccd..88e070f8cc 100644 --- a/src/Fable.Transforms/Replacements.fs +++ b/src/Fable.Transforms/Replacements.fs @@ -2702,7 +2702,7 @@ let stringModule | "Length", [ arg ] -> getFieldWith r t arg "length" |> Some | ("Iterate" | "IterateIndexed" | "ForAll" | "Exists"), _ -> // Cast the string to char[], see #1279 - let args = args |> List.replaceLast (fun e -> stringToCharArray e) + let args = args |> List.replaceLast stringToCharArray Helper.LibCall( com, @@ -2717,7 +2717,7 @@ let stringModule |> Some | ("Map" | "MapIndexed" | "Collect"), _ -> // Cast the string to char[], see #1279 - let args = args |> List.replaceLast (fun e -> stringToCharArray e) + let args = args |> List.replaceLast stringToCharArray let name = Naming.lowerFirst i.CompiledName emitExpr diff --git a/src/Fable.Transforms/Rust/AST/Rust.AST.Impl.fs b/src/Fable.Transforms/Rust/AST/Rust.AST.Impl.fs index 0308003341..5b5a820fb0 100644 --- a/src/Fable.Transforms/Rust/AST/Rust.AST.Impl.fs +++ b/src/Fable.Transforms/Rust/AST/Rust.AST.Impl.fs @@ -698,7 +698,7 @@ type VariantData with /// Return the `NodeId` of this variant's constructor, if it has one. member self.ctor_id() : Option = match self with - | VariantData.Struct(_, _) -> None + | VariantData.Struct(_) -> None | VariantData.Tuple(_, id) | VariantData.Unit(id) -> Some(id) diff --git a/src/Fable.Transforms/State.fs b/src/Fable.Transforms/State.fs index 3197db93fe..111480b03a 100644 --- a/src/Fable.Transforms/State.fs +++ b/src/Fable.Transforms/State.fs @@ -201,11 +201,7 @@ type Project = let inlineExprsDic = - implFiles - |> Map.values - |> Seq.map (fun f -> f.InlineExprs) - |> Seq.concat - |> dict + implFiles |> Map.values |> Seq.collect (fun f -> f.InlineExprs) |> dict let precompiledInfo = precompiledInfo diff --git a/src/fable-library-dart/Seq2.fs b/src/fable-library-dart/Seq2.fs index 2773329e79..3f94d666ce 100644 --- a/src/fable-library-dart/Seq2.fs +++ b/src/fable-library-dart/Seq2.fs @@ -47,9 +47,9 @@ let countBy for x in xs do let key = projection x - if dict.ContainsKey(key) then - dict[key] <- dict[key] + 1 - else + match dict.TryGetValue key with + | true, v -> dict[key] <- v + 1 + | false, _ -> dict[key] <- 1 keys.Add(key) diff --git a/src/fable-library-dart/Set.fs b/src/fable-library-dart/Set.fs index 0ae8291a17..6ad1713687 100644 --- a/src/fable-library-dart/Set.fs +++ b/src/fable-library-dart/Set.fs @@ -1041,7 +1041,7 @@ let union (set1: Set<'T>) (set2: Set<'T>) = set1 + set2 // [] let unionMany (sets: seq>) ([] comparer: IComparer<'T>) = - Seq.fold (fun s1 s2 -> s1 + s2) (Set<'T>.Empty comparer) sets + Seq.fold (+) (Set<'T>.Empty comparer) sets // [] let intersect (set1: Set<'T>) (set2: Set<'T>) = Set<'T>.Intersection(set1, set2) diff --git a/src/fable-library/Array.fs b/src/fable-library/Array.fs index 5eefa95798..c990c2ea89 100644 --- a/src/fable-library/Array.fs +++ b/src/fable-library/Array.fs @@ -637,7 +637,7 @@ let fold<'T, 'State> folder (state: 'State) (array: 'T[]) = // acc <- folder acc array.[i] // acc // else - foldImpl (fun acc x -> folder acc x) state array + foldImpl folder state array let iterate action (array: 'T[]) = for i = 0 to array.Length - 1 do diff --git a/src/fable-library/Set.fs b/src/fable-library/Set.fs index 8d4f249230..6d546aa2fb 100644 --- a/src/fable-library/Set.fs +++ b/src/fable-library/Set.fs @@ -1071,7 +1071,7 @@ let union (set1: Set<'T>) (set2: Set<'T>) = set1 + set2 // [] let unionMany (sets: seq>) ([] comparer: IComparer<'T>) = - Seq.fold (fun s1 s2 -> s1 + s2) (Set<'T>.Empty comparer) sets + Seq.fold (+) (Set<'T>.Empty comparer) sets // [] let intersect (set1: Set<'T>) (set2: Set<'T>) = Set<'T>.Intersection(set1, set2)