Skip to content

Commit 7f906c6

Browse files
authored
Merge pull request #1 from Krzysztof-Cieslak/patch-1
Remove Option.bind ;-)
2 parents 922e5f1 + 109acc7 commit 7f906c6

1 file changed

Lines changed: 20 additions & 26 deletions

File tree

src/FSharp.CosmosDb.Analyzer/CosmosCodeAnalysis.fs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ open FSharp.Compiler.Range
55
open FSharp.Compiler.SyntaxTree
66

77
module CosmosCodeAnalysis =
8+
89
let dotConcat = List.map(fun (id:Ident) -> id.idText) >> String.concat "."
10+
11+
let checkIfApply funcExpr argExpr range =
12+
match funcExpr with
13+
| SynExpr.Ident ident ->
14+
Some(ident.idText, argExpr, funcExpr.Range, range)
15+
| SynExpr.LongIdent (_, LongIdentWithDots (listOfIds, _), _, _) ->
16+
Some(dotConcat listOfIds, argExpr, funcExpr.Range, range)
17+
| _ ->
18+
None
19+
920
let (|Apply|_|) synExpr =
1021
match synExpr with
11-
| SynExpr.TypeApp (funcExpr, _, _, _, _, _, range) -> Some (funcExpr, funcExpr, range)
12-
| SynExpr.App (_, _, funcExpr, argExpr, range) -> Some (funcExpr, argExpr, range)
22+
| SynExpr.TypeApp (funcExpr, _, _, _, _, _, range) -> checkIfApply funcExpr funcExpr range
23+
| SynExpr.App (_, _, funcExpr, argExpr, range) -> checkIfApply funcExpr argExpr range
1324
| _ -> None
14-
|> Option.bind(fun (funcExpr, argExpr, range) ->
15-
match funcExpr with
16-
| SynExpr.Ident ident ->
17-
Some(ident.idText, argExpr, funcExpr.Range, range)
18-
| SynExpr.LongIdent (_, LongIdentWithDots (listOfIds, _), _, _) ->
19-
Some(dotConcat listOfIds, argExpr, funcExpr.Range, range)
20-
| _ ->
21-
None)
2225

2326
let (|LongIdent|_|) =
2427
function
@@ -39,31 +42,22 @@ module CosmosCodeAnalysis =
3942

4043
let (|TypedQuery|_|) synExpr =
4144
match synExpr with
42-
| SynExpr.App (_, _, (SynExpr.TypeApp (funcExpr, _, typeNames, _, _, _, typeAppRange)), SynExpr.Const (SynConst.String (query, _), _), _) ->
43-
Some {| FuncExpr = funcExpr; TypeNames = typeNames; Range = typeAppRange; Query = query |}
44-
| _ ->
45-
None
46-
|> Option.bind(fun args ->
47-
match args.FuncExpr with
48-
| SynExpr.LongIdent (_, LongIdentWithDots (listOfIds, _), _, _) ->
49-
Some {| args with Ids = listOfIds |}
50-
| _ ->
51-
None)
52-
|> Option.bind(fun args ->
53-
match dotConcat args.Ids with
45+
| SynExpr.App (_, _, (SynExpr.TypeApp (SynExpr.LongIdent (_, LongIdentWithDots (listOfIds, _), _, _), _, typeNames, _, _, _, typeAppRange)), SynExpr.Const (SynConst.String (query, _), _), _) ->
46+
match dotConcat listOfIds with
5447
| "Cosmos.query" ->
5548
let names =
56-
args.TypeNames
49+
typeNames
5750
|> List.choose (fun typeName ->
5851
match typeName with
5952
| SynType.LongIdent (LongIdentWithDots (listOfIds, _)) ->
6053
dotConcat listOfIds |> Some
6154
| _ ->
6255
None)
6356

64-
Some(names, args.Query, args.Range)
65-
| _ ->
66-
None)
57+
Some(names, query, typeAppRange)
58+
| _ -> None
59+
| _ ->
60+
None
6761

6862
let (|Database|_|) =
6963
function

0 commit comments

Comments
 (0)