Skip to content

Commit 09bf07a

Browse files
committed
Added haddocks and reasoning for watchkind helpers
1 parent fc54bc0 commit 09bf07a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lsp-types/src/Language/LSP/Protocol/Types/WatchKinds.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@ import Language.LSP.Protocol.Internal.Types (WatchKind(..))
44
import Language.LSP.Protocol.Types.LspEnum (toEnumBaseType, fromOpenEnumBaseType)
55
import Data.Set (toList, Set)
66

7+
-- WatchKind is better represented as a Set than as enum. As the lsp spec
8+
-- defines them as an enum, these helper functions help bridge the difference.
9+
10+
-- |Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
711
containsCreate :: WatchKind -> Bool
812
containsCreate WatchKind_Create = True
913
containsCreate (WatchKind_Custom 3) = True
1014
containsCreate (WatchKind_Custom 5) = True
1115
containsCreate (WatchKind_Custom 7) = True
1216
containsCreate _ = False
1317

18+
-- |Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
1419
containsChange :: WatchKind -> Bool
1520
containsChange WatchKind_Change = True
1621
containsChange (WatchKind_Custom 3) = True
1722
containsChange (WatchKind_Custom 6) = True
1823
containsChange (WatchKind_Custom 7) = True
1924
containsChange _ = False
2025

26+
-- |Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
2127
containsDelete :: WatchKind -> Bool
2228
containsDelete WatchKind_Delete = True
2329
containsDelete (WatchKind_Custom 5) = True
2430
containsDelete (WatchKind_Custom 6) = True
2531
containsDelete (WatchKind_Custom 7) = True
2632
containsDelete _ = False
2733

34+
-- |Combine a set of WatchKind types into a new WatchKind type that accurately
35+
-- represents the set
2836
combineWatchKinds :: Set WatchKind -> WatchKind
2937
combineWatchKinds s = fromOpenEnumBaseType $ sum $ toEnumBaseType <$> toList s

0 commit comments

Comments
 (0)