Skip to content

Commit

Permalink
Update src/Compiler/Utilities/illib.fs
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Rourke Boll <[email protected]>
  • Loading branch information
T-Gro and brianrourkeboll authored Jan 28, 2025
1 parent b4bb3a3 commit 52f12f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Compiler/Utilities/illib.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,10 +1308,12 @@ module MultiMap =
xs |> Seq.groupBy f |> Seq.map (fun (k, v) -> (k, List.ofSeq v)) |> Map.ofSeq

let ofList (xs: ('a * 'b) list) : MultiMap<'a,'b> =
xs
|> List.groupBy fst
|> List.map (fun (k, v) -> (k, List.map snd v))
|> Map.ofList
(Map.empty, xs)
||> List.fold (fun m (k, v) ->
m |> Map.change k (function
| None -> Some [v]
| Some vs -> Some (v :: vs)))
|> Map.map (fun _ values -> List.rev values)

type LayeredMap<'Key, 'Value when 'Key: comparison> = Map<'Key, 'Value>

Expand Down

0 comments on commit 52f12f4

Please sign in to comment.