th-lego 0.2.2 → 0.2.3
raw patch · 2 files changed
+28/−2 lines, 2 files
Files
- library/THLego/Helpers.hs +27/−1
- th-lego.cabal +1/−1
library/THLego/Helpers.hs view
@@ -2,7 +2,7 @@ where import THLego.Prelude-import Language.Haskell.TH+import Language.Haskell.TH.Syntax import qualified TemplateHaskell.Compat.V0208 as Compat import qualified Data.Text as Text @@ -106,6 +106,10 @@ [a] -> a a -> appliedTupleE a +nameString :: Name -> String+nameString (Name (OccName x) _) =+ x+ decimalIndexName :: Int -> Name decimalIndexName = mkName . showChar '_' . show@@ -147,3 +151,25 @@ eqConstraintT :: Name -> Type -> Type eqConstraintT name = AppT (AppT EqualityT (VarT name))+++-- *+-------------------------++applicativeChainE :: Exp -> [Exp] -> Exp+applicativeChainE mappingE apEList =+ case apEList of+ h : t ->+ intersperseInfixE+ (VarE '(<*>))+ (InfixE (Just mappingE) (VarE '(<$>)) (Just h) :| t)+ _ ->+ mappingE++intersperseInfixE :: Exp -> NonEmpty Exp -> Exp+intersperseInfixE op =+ foldl1 (\ l r -> InfixE (Just l) op (Just r))++textLitE :: Text -> Exp+textLitE =+ LitE . StringL . Text.unpack
th-lego.cabal view
@@ -1,5 +1,5 @@ name: th-lego-version: 0.2.2+version: 0.2.3 synopsis: Template Haskell construction utilities description: A collection of templates for the typical patterns appearing