Skip to content

Commit

Permalink
Remove CabalParsing class, specialize to ParsecParser
Browse files Browse the repository at this point in the history
Remove the `CharParsing` and `Parsing` classes, specialize all parsing logic to
`Parsec`. Rename the `Distribution.Parsec.Parsec` class to `CabalParsec` to
avoid ambiguity with `Text.Parsec.Parsec`.
  • Loading branch information
FinleyMcIlwaine committed Jun 17, 2024
1 parent 3169b87 commit ad1a0aa
Show file tree
Hide file tree
Showing 97 changed files with 776 additions and 1,163 deletions.
4 changes: 2 additions & 2 deletions Cabal-described/src/Distribution/Described.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)

import Distribution.Compat.Semigroup (Semigroup (..))
import Distribution.Parsec (Parsec, eitherParsec)
import Distribution.Parsec (CabalParsec, eitherParsec)
import Distribution.Pretty (Pretty, prettyShow)

import qualified Distribution.Utils.CharSet as CS
Expand Down Expand Up @@ -105,7 +105,7 @@ import Distribution.Version (Version, VersionRange)
import Language.Haskell.Extension (Extension, Language, knownLanguages)

-- | Class describing the pretty/parsec format of a.
class (Pretty a, Parsec a) => Described a where
class (Pretty a, CabalParsec a) => Described a where
-- | A pretty document of "regex" describing the field format
describe :: proxy a -> GrammarRegex void

Expand Down
2 changes: 0 additions & 2 deletions Cabal-syntax/Cabal-syntax.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ library
Distribution.Backpack
Distribution.CabalSpecVersion
Distribution.Compat.Binary
Distribution.Compat.CharParsing
Distribution.Compat.DList
Distribution.Compat.Exception
Distribution.Compat.Graph
Distribution.Compat.Lens
Distribution.Compat.MonadFail
Distribution.Compat.Newtype
Distribution.Compat.NonEmptySet
Distribution.Compat.Parsing
Distribution.Compat.Prelude
Distribution.Compat.Semigroup
Distribution.Compat.Typeable
Expand Down
10 changes: 5 additions & 5 deletions Cabal-syntax/src/Distribution/Backpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import Distribution.Pretty
import Text.PrettyPrint (hcat)
import Prelude ()

import qualified Distribution.Compat.CharParsing as P
import qualified Distribution.Parsec as P
import qualified Text.PrettyPrint as Disp

import Distribution.ModuleName
Expand Down Expand Up @@ -116,7 +116,7 @@ instance Pretty OpenUnitId where
--
-- >>> eitherParsec "foo[Str=text-1.2.3:Data.Text.Text]" :: Either String OpenUnitId
-- Right (IndefFullUnitId (ComponentId "foo") (fromList [(ModuleName "Str",OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "text-1.2.3"})) (ModuleName "Data.Text.Text"))]))
instance Parsec OpenUnitId where
instance CabalParsec OpenUnitId where
parsec = P.try parseOpenUnitId <|> fmap DefiniteUnitId parsec
where
parseOpenUnitId = do
Expand Down Expand Up @@ -184,7 +184,7 @@ instance Pretty OpenModule where
--
-- >>> eitherParsec "Includes2-0.1.0.0-inplace-mysql:Database.MySQL" :: Either String OpenModule
-- Right (OpenModule (DefiniteUnitId (DefUnitId {unDefUnitId = UnitId "Includes2-0.1.0.0-inplace-mysql"})) (ModuleName "Database.MySQL"))
instance Parsec OpenModule where
instance CabalParsec OpenModule where
parsec = parsecModuleVar <|> parsecOpenModule
where
parsecOpenModule = do
Expand Down Expand Up @@ -228,7 +228,7 @@ dispOpenModuleSubstEntry (k, v) = pretty k <<>> Disp.char '=' <<>> pretty v
-- | Inverse to 'dispModSubst'.
--
-- @since 2.2
parsecOpenModuleSubst :: CabalParsing m => m OpenModuleSubst
parsecOpenModuleSubst :: ParsecParser OpenModuleSubst
parsecOpenModuleSubst =
fmap Map.fromList
. flip P.sepBy (P.char ',')
Expand All @@ -237,7 +237,7 @@ parsecOpenModuleSubst =
-- | Inverse to 'dispModSubstEntry'.
--
-- @since 2.2
parsecOpenModuleSubstEntry :: CabalParsing m => m (ModuleName, OpenModule)
parsecOpenModuleSubstEntry :: ParsecParser (ModuleName, OpenModule)
parsecOpenModuleSubstEntry =
do
k <- parsec
Expand Down
Loading

0 comments on commit ad1a0aa

Please sign in to comment.