Applied more formatting; added Makefile #4

Merged
elland merged 3 commits from formatting into dev 2025-09-27 07:51:11 +00:00
4 changed files with 285 additions and 274 deletions

9
Makefile Normal file
View file

@ -0,0 +1,9 @@
.PHONY: help
help: ## Show this help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format
format:
find . -type f -name "*.hs" ! -path "./dist-newstyle/*" -exec fourmolu -i {} +
cabal-gild --io=haddock2.cabal

View file

@ -46,10 +46,10 @@ test-suite haddock2-test
type: exitcode-stdio-1.0
main-is: Spec.hs
build-depends:
parsec ^>=3.1.18.0,
base >=4.20.1.0,
haddock2:{haddock2-lib},
hspec ^>=2.11.0,
parsec ^>=3.1.18.0,
text ^>=2.1.2,
hs-source-dirs: test

View file

@ -4,7 +4,8 @@ module Lexer (
Token (..),
lexer,
emphasis,
) where
)
where
import Control.Monad (mfilter, void)
import Data.Functor (($>))
@ -17,6 +18,7 @@ import Text.Parsec qualified as Parsec
import Text.Parsec.Pos (updatePosChar)
type Located a = (SourcePos, a)
type LocatedToken = (SourcePos, Token)
type Lexer = Parser [LocatedToken]
@ -173,7 +175,6 @@ anchor = do
x <- located $ between "#" "#" (Anchor <$> anyUntil "#")
pure [x]
moduleNames :: Parser Text
moduleNames = intercalate "." . fmap Text.pack <$> upperId `sepBy1` char '.'
@ -302,6 +303,7 @@ scan ::
Parser Text
scan f initState = do
parserState@State{stateInput = input, statePos = pos} <- Parsec.getParserState
(remaining, finalPos, ct) <- go input initState pos 0
let newState = parserState{stateInput = remaining, statePos = finalPos}
Parsec.setParserState newState $> Text.take ct input

View file

@ -10,8 +10,8 @@ import Types
import Data.String (IsString (..))
import Data.Text (Text)
import Text.Parsec.Pos
import GHC.Stack
import Text.Parsec.Pos
main :: IO ()
main = hspec $ do