HListPP 0.2.1 → 0.2.2
raw patch · 3 files changed
+35/−19 lines, 3 filesdep −applicative-quotersdep ~base
Dependencies removed: applicative-quoters
Dependency ranges changed: base
Files
- ChangeLog +7/−0
- HListPP.cabal +21/−11
- HListPP.hs +7/−8
ChangeLog view
@@ -1,3 +1,10 @@+Apr 17 2020+Release 0.2.2+Remove applicative-quoters dependency in favor of -XApplicativeDo, which+restricts use to GHC>=8.0.1++Move to http://github.com/aavogt/HListPP+ Nov 6 2015 Release 0.2.1
HListPP.cabal view
@@ -1,15 +1,29 @@ name: HListPP-version: 0.2.1+version: 0.2.2 synopsis: A preprocessor for HList labelable labels description: A preprocessor that replaces @`longDescriptiveName@ with . > hLens' (Label :: Label "longDescriptiveName") .- Use with ghc flags @-F -pgmF HListPP@, which can- be added per-file with a pragma:+ Use with ghc flags @-F -pgmF HListPP@. A file using HListPP+ could start with something like . > ❴-# OPTIONS_GHC -F -pgmF HListPP #-❵ -- change braces to ascii (haddock doesn't allow literal comments in files)+ > ❴-# LANGUAGE DataKinds #-❵+ > import Data.HList.CommonMain+ > import Control.Lens .+ Then the labels can then be used in expressions with types+ like:+ .+ > `x :: Lens (Record S) (Record T) a b+ > `x :: Prism (Variant S) (Variant T) a b+ > `a .==. "x" .*.+ > `b .==. "y" .*. emptyRecord :: Record [ Tagged "a" String, Tagged "b" String ]+ .+ where @S@ is a type-level list containing a @Tagged "x" a@+ and @T@ is a type-level list containing a @Tagged "x" b@.+ . Note that @`labels@ is expanded to something that takes up about 26 more columns. To avoid issues with layout, put a newline after keywords that introduce@@ -30,11 +44,8 @@ > in if pos < 0 > then error msg > else pos- .- A blank library is included in this package to make- it possible to depend on HListPP -homepage: http://code.haskell.org/~aavogt/HListPP+homepage: http://github.com/aavogt/HListPP license: BSD3 license-file: LICENSE author: Adam Vogt <vogt.adam@gmail.com>@@ -45,13 +56,12 @@ extra-source-files: ChangeLog source-repository head- type: darcs- location: http://code.haskell.org/~aavogt/HListPP+ type: git+ location: http://github.com/aavogt/HListPP executable HListPP main-is: HListPP.hs other-extensions: QuasiQuotes, ViewPatterns- build-depends: base >=4.6 && <4.9,- applicative-quoters >=0.1 && <0.2,+ build-depends: base >=4.9 && <5, regex-applicative >=0.3 && <0.4 default-language: Haskell2010
HListPP.hs view
@@ -1,7 +1,6 @@-{-# LANGUAGE QuasiQuotes, ViewPatterns #-}+{-# LANGUAGE QuasiQuotes, ViewPatterns, ApplicativeDo #-} module Main where -import Control.Applicative.QQ.ADo import Data.Char import Data.List import Data.Monoid@@ -12,24 +11,24 @@ import System.IO -- "ModuleName."-modNameDot = [ado|+modNameDot = do m <- psym isUpper odName <- many (psym isAlpha <|> psym isDigit) dot <- sym '.'- m:odName ++ [dot] |]+ pure $ m:odName ++ [dot] -- "M.Od.Ule.Name.something"-qualIdent = [ado|+qualIdent = do modNames <- many modNameDot end <- identSym <|> identAlpha- concat (modNames ++ [end]) |]+ pure $ concat (modNames ++ [end]) identSym = some (psym isSymbol) -identAlpha = [ado|+identAlpha = do i <- psym isAlpha dent <- many (psym isAlpha <|> psym isDigit <|> sym '\'')- i:dent |]+ pure $ i:dent takeQual x = case findLongestPrefix qualIdent x of Just (a , '`' : rest) -> ('`' : a ++ "`", rest) -- `infix`