Update Megaparsec and Hedgehog
Getty Ritter
7 years ago
37 | 37 |
, Data.Ini.Config.Bidir
|
38 | 38 |
, Data.Ini.Config.Raw
|
39 | 39 |
ghc-options: -Wall
|
40 | |
build-depends: base >=4.7 && <5
|
| 40 |
build-depends: base >=4.8 && <5
|
41 | 41 |
, containers
|
42 | 42 |
, text >=1.2.2 && <1.3
|
43 | 43 |
, unordered-containers >=0.2.7 && <0.3
|
44 | 44 |
, transformers >=0.4.1 && <0.6
|
45 | |
, megaparsec >=5.1.2 && <5.2
|
| 45 |
, megaparsec >=6 && <7
|
46 | 46 |
default-language: Haskell2010
|
47 | 47 |
|
48 | 48 |
executable basic-example
|
26 | 26 |
import qualified Data.Text as T
|
27 | 27 |
import qualified Data.Text.Lazy as LazyText
|
28 | 28 |
import qualified Data.Text.Lazy.Builder as Builder
|
| 29 |
import Data.Void (Void)
|
29 | 30 |
import Text.Megaparsec
|
30 | |
import Text.Megaparsec.Text
|
| 31 |
import Text.Megaparsec.Char
|
| 32 |
|
| 33 |
type Parser = Parsec (ErrorFancy Void) Text
|
31 | 34 |
|
32 | 35 |
data NormalizedText = NormalizedText
|
33 | 36 |
{ actualText :: Text
|
61 | 61 |
(I2.normalizedText name, T.strip (I2.vValue value))
|
62 | 62 |
conv = HM.fromList . Fold.toList
|
63 | 63 |
|
64 | |
textChunk :: Monad m => Gen m Text
|
| 64 |
textChunk :: Gen Text
|
65 | 65 |
textChunk = fmap T.pack $ Gen.list (Range.linear 1 20) $ Gen.alphaNum
|
66 | 66 |
|
67 | |
mkIni :: Monad m => Gen m I1.Ini
|
| 67 |
mkIni :: Gen I1.Ini
|
68 | 68 |
mkIni = do
|
69 | 69 |
ss <- Gen.list (Range.linear 0 10) $ do
|
70 | 70 |
name <- textChunk
|
|
73 | 73 |
return (name, HM.fromList section)
|
74 | 74 |
return (I1.Ini (HM.fromList ss))
|
75 | 75 |
|
76 | |
mkComments :: Monad m => Gen m (Seq.Seq I2.BlankLine)
|
| 76 |
mkComments :: Gen (Seq.Seq I2.BlankLine)
|
77 | 77 |
mkComments = fmap Seq.fromList $ Gen.list (Range.linear 0 5) $
|
78 | 78 |
Gen.choice
|
79 | 79 |
[ return I2.BlankLine
|
80 | 80 |
, I2.CommentLine <$> Gen.element ";#" <*> textChunk
|
81 | 81 |
]
|
82 | 82 |
|
83 | |
mkRichIni :: Monad m => Gen m I2.RawIni
|
| 83 |
mkRichIni :: Gen I2.RawIni
|
84 | 84 |
mkRichIni = do
|
85 | 85 |
ss <- Gen.list (Range.linear 0 100) $ do
|
86 | 86 |
name <- textChunk
|