gdritter repos config-ini / 49c9660
Update Megaparsec and Hedgehog Getty Ritter 7 years ago
3 changed file(s) with 10 addition(s) and 7 deletion(s). Collapse all Expand all
3737 , Data.Ini.Config.Bidir
3838 , Data.Ini.Config.Raw
3939 ghc-options: -Wall
40 build-depends: base >=4.7 && <5
40 build-depends: base >=4.8 && <5
4141 , containers
4242 , text >=1.2.2 && <1.3
4343 , unordered-containers >=0.2.7 && <0.3
4444 , transformers >=0.4.1 && <0.6
45 , megaparsec >=5.1.2 && <5.2
45 , megaparsec >=6 && <7
4646 default-language: Haskell2010
4747
4848 executable basic-example
2626 import qualified Data.Text as T
2727 import qualified Data.Text.Lazy as LazyText
2828 import qualified Data.Text.Lazy.Builder as Builder
29 import Data.Void (Void)
2930 import Text.Megaparsec
30 import Text.Megaparsec.Text
31 import Text.Megaparsec.Char
32
33 type Parser = Parsec (ErrorFancy Void) Text
3134
3235 data NormalizedText = NormalizedText
3336 { actualText :: Text
6161 (I2.normalizedText name, T.strip (I2.vValue value))
6262 conv = HM.fromList . Fold.toList
6363
64 textChunk :: Monad m => Gen m Text
64 textChunk :: Gen Text
6565 textChunk = fmap T.pack $ Gen.list (Range.linear 1 20) $ Gen.alphaNum
6666
67 mkIni :: Monad m => Gen m I1.Ini
67 mkIni :: Gen I1.Ini
6868 mkIni = do
6969 ss <- Gen.list (Range.linear 0 10) $ do
7070 name <- textChunk
7373 return (name, HM.fromList section)
7474 return (I1.Ini (HM.fromList ss))
7575
76 mkComments :: Monad m => Gen m (Seq.Seq I2.BlankLine)
76 mkComments :: Gen (Seq.Seq I2.BlankLine)
7777 mkComments = fmap Seq.fromList $ Gen.list (Range.linear 0 5) $
7878 Gen.choice
7979 [ return I2.BlankLine
8080 , I2.CommentLine <$> Gen.element ";#" <*> textChunk
8181 ]
8282
83 mkRichIni :: Monad m => Gen m I2.RawIni
83 mkRichIni :: Gen I2.RawIni
8484 mkRichIni = do
8585 ss <- Gen.list (Range.linear 0 100) $ do
8686 name <- textChunk