blob: 009c6e639e9703f7c196a3a76e375b4a97ad576b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module Comment.Language
( Language (..),
fromExtension,
parser,
lineStart,
block,
nodeTypes,
)
where
import Control.Exception (throw)
import Data.Binary (Binary)
import Data.Text qualified as T
import Exception qualified as E
import Foreign.Ptr (Ptr)
import GHC.Generics (Generic)
import TreeSitter.Haskell qualified as S
import TreeSitter.Language qualified as S
data Language
= Haskell
deriving (Eq, Show, Generic, Binary)
fromExtension :: String -> Language
fromExtension ".hs" = Haskell
fromExtension ext = throw $ E.UnknownFileExtension ext
-- TODO add languages elm, shell, nix
parser :: Language -> Ptr S.Language
parser Haskell = S.tree_sitter_haskell
lineStart :: Language -> T.Text
lineStart Haskell = "--"
block :: Language -> Maybe ([T.Text], T.Text)
block Haskell = Just (["{-"], "-}")
nodeTypes :: Language -> [String]
nodeTypes Haskell = ["comment"]
|