Skip to content

Commit

Permalink
Add doctests for Parsec PkgconfigVersion
Browse files Browse the repository at this point in the history
Related to haskell#6539
  • Loading branch information
phadej committed Feb 14, 2020
1 parent 97a3afe commit f9e8024
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cabal/Distribution/Types/PkgconfigVersion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ instance NFData PkgconfigVersion where rnf = genericRnf
instance Pretty PkgconfigVersion where
pretty (PkgconfigVersion bs) = PP.text (BS8.unpack bs)

-- |
--
-- >>> simpleParsec "1.0.2n" :: Maybe PkgconfigVersion
-- Just (PkgconfigVersion "1.0.2n")
--
-- >>> simpleParsec "0.3.5+ds" :: Maybe PkgconfigVersion
-- Nothing
--
instance Parsec PkgconfigVersion where
parsec = PkgconfigVersion . BS8.pack <$> P.munch1 predicate where
predicate c = isAsciiAlphaNum c || c == '.' || c == '-'
Expand Down

0 comments on commit f9e8024

Please sign in to comment.