Created
April 27, 2022 10:37
-
-
Save dsyme/b1b560e5ff6c152a40ef4f4835a75b63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<Sealed>] | |
type LongIdentWithTrivia(lid: LongIdent, dotRanges: range list, ?trivia: IdentTrivia option list) = | |
let triviaStored = | |
match trivia with | |
| None -> ValueNone | |
| Some l when l |> List.forall Option.isNone -> ValueNone | |
| Some l -> ValueSome (Array.ofList l) | |
let getTrivia() = | |
match triviaStored with | |
| ValueNone -> lid |> List.map (fun _ -> None) | |
| ValueSome l -> Array.toList l | |
member _.LongIdent = lid | |
member _.DotRanges = dotRanges | |
member _.IdentsTrivia = getTrivia() | |
member _.IdentsWithTrivia = (lid, getTrivia()) ||> List.zip | |
[<AutoOpen>] | |
module LongIdentWithTriviaHelpers = | |
let (|LongIdentWithDots|) (lid: LongIdentWithTrivia) = lid.LongIdent, lid.DotRanges | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment