Skip to content

Commit 91481c0

Browse files
committed
Formatting changes from GuillaumedeVolpiano
Signed-off-by: hololeap <hololeap@protonmail.com>
1 parent 31c7a1f commit 91481c0

File tree

6 files changed

+181
-190
lines changed

6 files changed

+181
-190
lines changed

parsable-test/src/Test/Parsable.hs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Module : Test.Parsable
44
Test functions for 'Parsable' and 'Printable'.
55
-}
66

7-
{-# Language CPP #-}
8-
{-# Language DerivingVia #-}
9-
{-# Language FlexibleContexts #-}
10-
{-# Language LambdaCase #-}
11-
{-# Language ScopedTypeVariables #-}
12-
{-# Language TupleSections #-}
13-
{-# Language TypeApplications #-}
7+
{-# LANGUAGE CPP #-}
8+
{-# LANGUAGE DerivingVia #-}
9+
{-# LANGUAGE FlexibleContexts #-}
10+
{-# LANGUAGE LambdaCase #-}
11+
{-# LANGUAGE ScopedTypeVariables #-}
12+
{-# LANGUAGE TupleSections #-}
13+
{-# LANGUAGE TypeApplications #-}
1414

1515
module Test.Parsable
1616
(
@@ -35,19 +35,18 @@ module Test.Parsable
3535
, module Data.Void
3636
) where
3737

38-
import Control.Monad.STM
39-
import Control.Concurrent.STM.TChan
40-
import Data.ByteString (ByteString)
38+
import Control.Concurrent.STM.TChan
39+
import Control.Monad.STM
40+
import Data.ByteString (ByteString)
4141
import Data.ByteString.Char8 (pack)
42-
import Data.Function (fix)
43-
import Data.Semigroup (Last(..))
44-
import Data.Typeable
45-
import Data.Void
46-
import Test.Tasty
47-
import Test.Tasty.HUnit
48-
import Test.Tasty.QuickCheck hiding (checkCoverage)
49-
50-
import Data.Parsable
42+
import Data.Function (fix)
43+
import Data.Parsable
44+
import Data.Semigroup (Last (..))
45+
import Data.Typeable
46+
import Data.Void
47+
import Test.Tasty
48+
import Test.Tasty.HUnit
49+
import Test.Tasty.QuickCheck hiding (checkCoverage)
5150

5251
-- | If a parse succeeds for the beginning of the input, but then fails, we
5352
-- choose the 'PartialParse' constructor. If the entire parse was successful,

parsable/parsable.cabal

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,74 @@
1-
cabal-version: 3.0
2-
name: parsable
3-
version: 0.2.0.0
4-
synopsis: Parsable and Printable classes
5-
6-
tested-with: GHC == { 9.4.8, 9.6.7, 9.8.4, 9.10.1, 9.12.2 }
7-
1+
cabal-version: 3.0
2+
name: parsable
3+
version: 0.2.0.0
4+
synopsis: Parsable and Printable classes
5+
tested-with: GHC ==9.4.8 || ==9.6.7 || ==9.8.4 || ==9.10.1 || ==9.12.2
86
description:
9-
Provides the Parsable and Printable classes, which form a round-trip
10-
equivalence between a data type and a String. Useful for types that
11-
are generated directly from a String and need their internal
12-
representation to be converted back to a String.
13-
14-
homepage: https://github.com/gentoo-haskell/cabal-portage/tree/main/parsable
15-
bug-reports: https://github.com/gentoo-haskell/cabal-portage/issues
7+
Provides the Parsable and Printable classes, which form a round-trip
8+
equivalence between a data type and a String. Useful for types that
9+
are generated directly from a String and need their internal
10+
representation to be converted back to a String.
1611

17-
license: AGPL-3.0-only
18-
license-file: LICENSE
19-
author: Gentoo Authors
20-
maintainer: hololeap@protonmail.com
12+
homepage:
13+
https://github.com/gentoo-haskell/cabal-portage/tree/main/parsable
2114

22-
copyright: Copyright (C) 2022-2025 Gentoo Authors
23-
category: Text
24-
extra-doc-files:
25-
, CHANGELOG.md
15+
bug-reports: https://github.com/gentoo-haskell/cabal-portage/issues
16+
license: AGPL-3.0-only
17+
license-file: LICENSE
18+
author: Gentoo Authors
19+
maintainer: hololeap@protonmail.com
20+
copyright: Copyright (C) 2022-2025 Gentoo Authors
21+
category: Text
22+
extra-doc-files: CHANGELOG.md
2623

2724
source-repository head
28-
type: git
29-
location: https://github.com/gentoo-haskell/cabal-portage.git
30-
branch: main
31-
subdir: parsable
25+
type: git
26+
location: https://github.com/gentoo-haskell/cabal-portage.git
27+
branch: main
28+
subdir: parsable
3229

3330
flag pedantic
34-
description: Enable -Werror
35-
default: False
36-
manual: True
31+
description: Enable -Werror
32+
default: False
33+
manual: True
3734

3835
common all
39-
ghc-options: -Wall
40-
-foptimal-applicative-do
41-
if flag(pedantic)
42-
ghc-options: -Werror
36+
ghc-options: -Wall -foptimal-applicative-do
4337

44-
library
45-
import: all
46-
exposed-modules:
47-
, Data.Parsable
38+
if flag(pedantic)
39+
ghc-options: -Werror
4840

49-
other-extensions:
50-
, ConstrainedClassMethods
51-
, DefaultSignatures
52-
, DeriveTraversable
53-
, FlexibleContexts
54-
, FlexibleInstances
55-
, LambdaCase
56-
, TypeFamilies
41+
library
42+
import: all
43+
exposed-modules: Data.Parsable
44+
other-extensions:
45+
ConstrainedClassMethods
46+
DefaultSignatures
47+
DeriveTraversable
48+
FlexibleContexts
49+
FlexibleInstances
50+
LambdaCase
51+
TypeFamilies
5752

58-
build-depends:
59-
, base >=4.13 && <4.22
60-
, bytestring >=0.12.0.0 && <0.13
61-
, flatparse >=0.5.2.0 && <0.5.3
62-
, transformers <0.7
63-
, text <2.2
64-
hs-source-dirs: src
65-
default-language: Haskell2010
53+
build-depends:
54+
, base >=4.13 && <4.22
55+
, bytestring >=0.12.0.0 && <0.13
56+
, flatparse >=0.5.2.0 && <0.5.3
57+
, text <2.2
58+
, transformers <0.7
6659

67-
other-extensions:
68-
, ConstrainedClassMethods
69-
, DefaultSignatures
70-
, DeriveGeneric
71-
, DeriveTraversable
72-
, DerivingVia
73-
, FlexibleContexts
74-
, FlexibleInstances
75-
, GeneralizedNewtypeDeriving
76-
, LambdaCase
77-
, ScopedTypeVariables
78-
, TypeApplications
79-
, TypeFamilies
60+
hs-source-dirs: src
61+
default-language: Haskell2010
62+
other-extensions:
63+
ConstrainedClassMethods
64+
DefaultSignatures
65+
DeriveGeneric
66+
DeriveTraversable
67+
DerivingVia
68+
FlexibleContexts
69+
FlexibleInstances
70+
GeneralizedNewtypeDeriving
71+
LambdaCase
72+
ScopedTypeVariables
73+
TypeApplications
74+
TypeFamilies

parsable/src/Data/Parsable.hs

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ Look at the @Language Extensions@ section of the GHC documentation for
1919
instructions on how to use these extensions.
2020
-}
2121

22-
{-# Language DataKinds #-}
23-
{-# Language DefaultSignatures #-}
24-
{-# Language DeriveDataTypeable #-}
25-
{-# Language DeriveGeneric #-}
26-
{-# Language DeriveTraversable #-}
27-
{-# Language DerivingVia #-}
28-
{-# Language FlexibleContexts #-}
29-
{-# Language FlexibleInstances #-}
30-
{-# Language GeneralizedNewtypeDeriving #-}
31-
{-# Language MultiParamTypeClasses #-}
32-
{-# Language OverloadedStrings #-}
33-
{-# Language QuantifiedConstraints #-}
34-
{-# Language ScopedTypeVariables #-}
35-
{-# Language TypeApplications #-}
36-
{-# Language TypeFamilies #-}
37-
{-# Language UndecidableInstances #-}
22+
{-# LANGUAGE DataKinds #-}
23+
{-# LANGUAGE DefaultSignatures #-}
24+
{-# LANGUAGE DeriveDataTypeable #-}
25+
{-# LANGUAGE DeriveGeneric #-}
26+
{-# LANGUAGE DeriveTraversable #-}
27+
{-# LANGUAGE DerivingVia #-}
28+
{-# LANGUAGE FlexibleContexts #-}
29+
{-# LANGUAGE FlexibleInstances #-}
30+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
31+
{-# LANGUAGE MultiParamTypeClasses #-}
32+
{-# LANGUAGE OverloadedStrings #-}
33+
{-# LANGUAGE QuantifiedConstraints #-}
34+
{-# LANGUAGE ScopedTypeVariables #-}
35+
{-# LANGUAGE TypeApplications #-}
36+
{-# LANGUAGE TypeFamilies #-}
37+
{-# LANGUAGE UndecidableInstances #-}
3838

3939
module Data.Parsable
4040
(
@@ -68,22 +68,22 @@ module Data.Parsable
6868
, STMode
6969
) where
7070

71-
import Control.Applicative hiding (many)
72-
import Control.Monad
73-
import Control.Monad.ST (ST)
74-
import Control.Monad.Trans.Class
75-
import Data.ByteString (ByteString)
76-
import Data.Char hiding (isDigit)
77-
import Data.Data
78-
import Data.Functor.Identity
79-
import Data.String
80-
import Data.Text (Text, unpack)
81-
import FlatParse.Basic
82-
import FlatParse.Basic.Text
83-
import FlatParse.Common.Parser (IOMode, PureMode, STMode)
84-
import GHC.Exts (ZeroBitType)
85-
import GHC.Generics
86-
import Text.Read (readMaybe)
71+
import Control.Applicative hiding (many)
72+
import Control.Monad
73+
import Control.Monad.ST (ST)
74+
import Control.Monad.Trans.Class
75+
import Data.ByteString (ByteString)
76+
import Data.Char hiding (isDigit)
77+
import Data.Data
78+
import Data.Functor.Identity
79+
import Data.String
80+
import Data.Text (Text, unpack)
81+
import FlatParse.Basic
82+
import FlatParse.Basic.Text
83+
import FlatParse.Common.Parser (IOMode, PureMode, STMode)
84+
import GHC.Exts (ZeroBitType)
85+
import GHC.Generics
86+
import Text.Read (readMaybe)
8787

8888
newtype ParserName a (st :: ZeroBitType) e = ParserName { getParserName :: String }
8989
deriving stock (Show, Eq, Ord)
@@ -104,7 +104,7 @@ instance (Read a, Typeable a)
104104
parser = (<?> "natural number") $ do
105105
ds <- some (satisfy isDigit)
106106
case readMaybe ds of
107-
Just i -> pure $ NaturalParsable i
107+
Just i -> pure $ NaturalParsable i
108108
Nothing -> err $ "Could not parse as " ++ t ++ ": " ++ show ds
109109
where
110110
t = show $ typeRep $ Proxy @a
@@ -151,8 +151,7 @@ satisfyAny fs = satisfy $ \c -> or [f c | f <- fs]
151151
-- | Parsing of "words" which require a list of predicates for the first
152152
-- token, and a list of predicates for any remaining tokens. This always
153153
-- parses at least one token.
154-
wordAllowed
155-
:: [Char -> Bool] -- ^ Tokens that start the word
154+
wordAllowed :: [Char -> Bool] -- ^ Tokens that start the word
156155
-> [Char -> Bool] -- ^ Any subsequent tokens
157156
-> ParserT st e [Char]
158157
wordAllowed beg rest = (:) <$> satisfyAny beg <*> many (satisfyAny rest)

0 commit comments

Comments
 (0)