1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Define a TermProjection datatype.

This commit is contained in:
Rob Rix 2017-03-31 22:32:29 -04:00
parent 1cd2b5456b
commit c3b849105f

View File

@ -1,4 +1,4 @@
{-# LANGUAGE DataKinds, ScopedTypeVariables, TypeFamilies, TypeOperators #-}
{-# LANGUAGE DataKinds, GADTs, ScopedTypeVariables, TypeFamilies, TypeOperators #-}
module Command.Parse where
import Arguments
@ -83,6 +83,10 @@ parseRoot construct combine args@Arguments{..} = do
makeNode (head :. range :. category :. sourceSpan :. Nil) syntax =
ParseNode (toS category) range head sourceSpan (identifierFor syntax)
data TermProjection (fields :: [*]) output where
Index :: Maybe Source -> TermProjection fields [ParseNode]
ParseTree :: Maybe Source -> TermProjection fields (Rose ParseNode)
-- | Constructs IndexFile nodes for the provided arguments and encodes them to JSON.
parseIndex :: Arguments -> IO ByteString
parseIndex = fmap (toS . encode) . parseRoot IndexFile (\ node siblings -> node : concat siblings)