Skip to content

Commit

Permalink
Handle multi-operator fixity declarations in the extraction script
Browse files Browse the repository at this point in the history
  • Loading branch information
tbagrel1 authored and mrkkrp committed Dec 17, 2021
1 parent d477a0b commit aa9ea5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion extract-hackage-info/hackage-info.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions extract-hackage-info/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

module Main (main) where
Expand Down Expand Up @@ -295,15 +296,20 @@ extractFixitiesFromFile
foldl' @[]
(onFixityDecl packageName)
state'
(fromFixityDecl <$> fixityDecls fileContent)
(concatMap @[] fromFixityDecl $ fixityDecls fileContent)
fromSymbolDecl match = capture @"declOpName" match
fromFixityDecl match =
( capture @"fixDir" match,
capture @"fixPrec" match,
(capture @"fixDir" match,capture @"fixPrec" match,)
<$> splitInfixOpNames (capture @"infixOpNames" match)
splitInfixOpNames "" = []
splitInfixOpNames s = case [regex|^(?:\s*?,\s*?)?(?<infixOpName>[^,\s]+)(?<remaining>.*)$|] s of
[match] ->
capture @"infixOpName" match
)
: splitInfixOpNames (capture @"remaining" match)
_ -> error $ "remaining text: " ++ T.unpack s

symbolDecls = [regex|(?m)^\s*?(?<declOpName>\([^)]+?\))\s*?::.*$|]
fixityDecls = [regex|(?m)^\s*?(?<fixDir>infix[rl]?)\s+?(?<fixPrec>[0-9])\s+?(?<infixOpName>[^\s]+)\s*$|]
fixityDecls = [regex|(?m)^\s*?(?<fixDir>infix[rl]?)\s+?(?<fixPrec>[0-9])\s+?(?<infixOpNames>(?:[^,\s]+\s*?,\s*?)*?[^,\s]+)\s*$|]
return state'' {sProcessedFiles = sProcessedFiles + 1}

-- | Process the whole Hoogle database and return a map associating each
Expand Down

0 comments on commit aa9ea5e

Please sign in to comment.