stan-0.2.0.0: Haskell STatic ANalyser

Copyright | (c) 2020 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Safe Haskell | None
Language | Haskell2010

Stan.Hie

Description

Functions to work with `hie` specific parts.

Synopsis

- readHieFiles :: FilePath -> IO [HieFile]
- countLinesOfCode :: HieFile -> Int
- eqAst :: Ord a => HieFile -> HieAST a -> HieAST a -> Bool
- slice :: RealSrcSpan -> ByteString -> Maybe ByteString

# Documentation

readHieFiles :: FilePath -> IO [HieFile] #

Returns contents of all `.hie` files recursively in the given `hie` directory.

countLinesOfCode :: HieFile -> Int #

Get the number of lines of code in the file by analising `HieFile`.

eqAst :: Ord a => HieFile -> HieAST a -> HieAST a -> Bool #

Compare two AST nodes on equality. This is a more relaxed version of the `Eq` instance for `HieAST` because it doesn't compare source locations. This function is useful if you want to check whether two AST nodes represent the same AST.

This function needs to take the original `HieFile` because constants are not stored in `HieAST` and to compare constants we need to compare parts of source code.

slice :: RealSrcSpan -> ByteString -> Maybe ByteString #

Take sub-bytestring according to a given span.

When the given source is empty returns `Nothing`.

TODO: currently works only with single-line spans