ghc-tags-core-0.2.1.0: a library to work with tags created from Haskell parsed tree

Safe HaskellNone
LanguageHaskell2010

GhcTags.Tag

Contents

Synopsis

Tag

data TAG_KIND Source #

Promoted data type used to disntinguish CTAGs from ETAGs.

Constructors

CTAG 
ETAG 

data SingTagKind (tk :: TAG_KIND) where Source #

Singletons for promoted types.

data Tag (tk :: TAG_KIND) Source #

Tag record. For either ctags or etags formats. It is either filled with information parsed from a tags file or from *GHC* ast.

Constructors

Tag 

Fields

Instances
Eq (Tag tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

(==) :: Tag tk -> Tag tk -> Bool #

(/=) :: Tag tk -> Tag tk -> Bool #

Show (Tag tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

showsPrec :: Int -> Tag tk -> ShowS #

show :: Tag tk -> String #

showList :: [Tag tk] -> ShowS #

Tag fields

newtype TagName Source #

ByteString which encodes a tag name.

Constructors

TagName 

Fields

Instances
Eq TagName Source # 
Instance details

Defined in GhcTags.Tag

Methods

(==) :: TagName -> TagName -> Bool #

(/=) :: TagName -> TagName -> Bool #

Ord TagName Source # 
Instance details

Defined in GhcTags.Tag

Show TagName Source # 
Instance details

Defined in GhcTags.Tag

newtype ExCommand Source #

Constructors

ExCommand 

Fields

Instances
Eq ExCommand Source # 
Instance details

Defined in GhcTags.Tag

Ord ExCommand Source # 
Instance details

Defined in GhcTags.Tag

Show ExCommand Source # 
Instance details

Defined in GhcTags.Tag

data TagAddress (tk :: TAG_KIND) where Source #

Tag address, either from a parsed file or from Haskell's AST>

Constructors

TagLineCol :: !Int -> !Int -> TagAddress tk

Precise addres: line and column. This is what we infer from GHC AST.

The two arguments are line number and either column number or offset from the begining of the file.

TagLine :: !Int -> TagAddress CTAG

ctags can only use range ex-commands as an address (or a sequence of them separated by `;`). We parse line number specifically, since they are useful for ordering tags.

TagCommand :: !ExCommand -> TagAddress CTAG

A tag address can be just an ex command.

Instances
Eq (TagAddress tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

(==) :: TagAddress tk -> TagAddress tk -> Bool #

(/=) :: TagAddress tk -> TagAddress tk -> Bool #

Ord (TagAddress tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

compare :: TagAddress tk -> TagAddress tk -> Ordering #

(<) :: TagAddress tk -> TagAddress tk -> Bool #

(<=) :: TagAddress tk -> TagAddress tk -> Bool #

(>) :: TagAddress tk -> TagAddress tk -> Bool #

(>=) :: TagAddress tk -> TagAddress tk -> Bool #

max :: TagAddress tk -> TagAddress tk -> TagAddress tk #

min :: TagAddress tk -> TagAddress tk -> TagAddress tk #

Show (TagAddress tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

showsPrec :: Int -> TagAddress tk -> ShowS #

show :: TagAddress tk -> String #

showList :: [TagAddress tk] -> ShowS #

data TagKind (tk :: TAG_KIND) where Source #

When we parse a tags file we can eithera find no kind or recognize the kind of GhcTagKind or we store the found character kind. This allows us to preserve information from parsed tags files which were not created by `ghc-tags-plugin'

Instances
Eq (TagKind tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

(==) :: TagKind tk -> TagKind tk -> Bool #

(/=) :: TagKind tk -> TagKind tk -> Bool #

Ord (TagKind tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

compare :: TagKind tk -> TagKind tk -> Ordering #

(<) :: TagKind tk -> TagKind tk -> Bool #

(<=) :: TagKind tk -> TagKind tk -> Bool #

(>) :: TagKind tk -> TagKind tk -> Bool #

(>=) :: TagKind tk -> TagKind tk -> Bool #

max :: TagKind tk -> TagKind tk -> TagKind tk #

min :: TagKind tk -> TagKind tk -> TagKind tk #

Show (TagKind tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

showsPrec :: Int -> TagKind tk -> ShowS #

show :: TagKind tk -> String #

showList :: [TagKind tk] -> ShowS #

data TagDefinition (tk :: TAG_KIND) where Source #

Emacs tags specific field.

Instances
Eq (TagDefinition tk) Source # 
Instance details

Defined in GhcTags.Tag

Show (TagDefinition tk) Source # 
Instance details

Defined in GhcTags.Tag

data TagFields (tk :: TAG_KIND) where Source #

Ctags specific list of TagFields.

Instances
Eq (TagFields tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

(==) :: TagFields tk -> TagFields tk -> Bool #

(/=) :: TagFields tk -> TagFields tk -> Bool #

Show (TagFields tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

showsPrec :: Int -> TagFields tk -> ShowS #

show :: TagFields tk -> String #

showList :: [TagFields tk] -> ShowS #

Semigroup (TagFields tk) Source # 
Instance details

Defined in GhcTags.Tag

Methods

(<>) :: TagFields tk -> TagFields tk -> TagFields tk #

sconcat :: NonEmpty (TagFields tk) -> TagFields tk #

stimes :: Integral b => b -> TagFields tk -> TagFields tk #

Monoid (TagFields CTAG) Source # 
Instance details

Defined in GhcTags.Tag

Monoid (TagFields ETAG) Source # 
Instance details

Defined in GhcTags.Tag

data TagField Source #

Unit of data associated with a tag. Vim natively supports `file:` and `kind:` tags but it can display any other tags too.

Constructors

TagField 

Fields

Instances
Eq TagField Source # 
Instance details

Defined in GhcTags.Tag

Ord TagField Source # 
Instance details

Defined in GhcTags.Tag

Show TagField Source # 
Instance details

Defined in GhcTags.Tag

Ordering and combining tags

compareTags :: forall (tk :: TAG_KIND). Ord (TagAddress tk) => Tag tk -> Tag tk -> Ordering Source #

Total order relation on Tag elements.

It sorts type classes / type families (TkTypeClass, TkTypeFamily, TkDataTypeFamily) before instances (TkTypeClassInstance, TkTypeFamilyInstance, TkDataTypeFamilyInstance); but also (as a side effect of keeping transitivity property) it will put type classes and their instances before other kinds.

It satisfies the following properties:

  • anti-symmetry
  • reflexivity
  • transitivity
  • partial consistency with Eq instance:
a == b => compareTags a b == EQ

combineTags :: (Tag tk -> Tag tk -> Ordering) -> RawFilePath -> [Tag tk] -> [Tag tk] -> [Tag tk] Source #

Combine tags from a single GHC module with tags read from a tags file with respect to the given ordering function, e.g. orderTags or orderTags.

This is performance crtitical function. Tags from the first list are assumeed to be from the same file.

complexity: O(max n m)

Create Tag from a GhcTag

ghcTagToTag :: SingTagKind tk -> DynFlags -> GhcTag -> Maybe (Tag tk) Source #

Create a Tag from GhcTag.