packages feed

applicative-quoters 0.1.0.5 → 0.1.0.6

raw patch · 6 files changed

+87/−37 lines, 6 filesdep +notcppdep ~basedep ~haskell-src-metadep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependencies added: notcpp

Dependency ranges changed: base, haskell-src-meta, template-haskell

API changes (from Hackage documentation)

Files

+ ChangeLog view
@@ -0,0 +1,31 @@+0.1.0.6:+- Use the notcpp package to aid with name lookup+- Compatibility with GHC 7.6.1 and TH 2.8+- Drop compatibility with GHC < 7.4 to fix a bug with infix handling+- Doc improvements+- Remove maintainer++0.1.0.5:+- Mostly a rerelease of 0.1.0.4 to fix some metadata++0.1.0.4:+- GHC 7.4 compatibility++0.1.0.3:+- Dependency update+- Support infix applications in idiom brackets++0.1.0.2:+- GHC 7.2 compatibility++0.1.0.1:+- Stop ado' needlessly checking failing patterns+- Make a better effort to resolve constructor names++0.1:+- Quasiquoters extracted from haskell-src-meta+- Module names changed to Control.Applicative.QQ.{ADo,Idiom}+- Stop stripping qualification from names+- Fixes for failing pattern detection in ado+- Drop dependency on syb and containers+- quotePat fields removed
Control/Applicative/QQ/ADo.hs view
@@ -31,7 +31,7 @@ import Control.Monad import Data.Data (cast, gmapQ) -import Magic+import NotCPP.ScopeLookup (scopeLookup)  -- $desugaring --@@ -110,7 +110,13 @@ ado' = ado'' True  ado'' ::  Bool -> QuasiQuoter-ado'' b = QuasiQuoter { quoteExp = \str -> applicate b =<< parseDo str }+ado'' b = QuasiQuoter { quoteExp = \str -> applicate b =<< parseDo str,+  quotePat = nonsense "pattern",+  quoteType = nonsense "type",+  quoteDec = nonsense "declaration" }+ where+  nonsense context = fail $ "You can't use ado in " ++ context +++    " context, that doesn't even make sense."  parseDo ::  (Monad m) => String -> m [Stmt] parseDo str =@@ -170,7 +176,7 @@ -- | Given a 'Name' of a value constructor, find the 'TyConI dec' of its -- type, and return 'dec' findTyCon :: Name -> Q Dec-findTyCon n = case $(maybeVar "lookupValueName") of+findTyCon n = case $(scopeLookup "lookupValueName") of   Just fn -> do     DataConI _ _ tn _ <- maybe noScope reify =<< fn (show n)     TyConI dec <- reify tn
Control/Applicative/QQ/Idiom.hs view
@@ -11,15 +11,41 @@ import Language.Haskell.TH.Quote import Language.Haskell.TH.Syntax --- ghci> [$i| (,) "foo" "bar" |]--- [('f','b'),('f','a'),('f','r'),('o','b'),('o','a'),('o','r'),('o','b'),('o','a'),('o','r')]+-- | Turns function application into <*>, and puts a pure on the beginning.+--+-- [i| subtract [1,2,3] [10,20,30] |]+-- -> pure subtract <*> [1,2,3] <*> [10,20,30]+-- -> [99,199,299,98,198,298,97,197,297]+--+-- Does not apply to nested applications:+--+-- getZipList [i| subtract (ZipList [1,2,3]) (ZipList [100,200,300]) |]+-- -> getZipList (pure subtract <*> ZipList [1,2,3] <*> ZipList [100,200,300])+-- -> [99,198,297]+--+-- Will treat [i| x `op` y |] as [i| op x y |] as long as neither x nor y+-- are an infix expression. The precise behaviour when x or y are infix+-- applications depends on what haskell-src-meta does, which depends on what+-- TH supports, so may depend on your GHC version. i :: QuasiQuoter-i = QuasiQuoter { quoteExp = applicate <=< either fail return . parseExp }+i = QuasiQuoter { quoteExp = applicate <=< either fail return . parseExp,+  quotePat = nonsense "pattern",+  quoteType = nonsense "type",+  quoteDec = nonsense "dec" }+ where+  nonsense context = fail $ "You can't use idiom brackets in " ++ context +++    " context, that doesn't even make sense."  applicate :: Exp -> ExpQ applicate (AppE f x) =   [| $(applicate f) <*> $(return x) |] applicate (InfixE (Just left) op (Just right)) =   [| pure $(return op) <*> $(return left) <*> $(return right) |]+applicate (UInfixE left op right) = case (left,right) of+  (UInfixE{}, _) -> ambig+  (_, UInfixE{}) -> ambig+  (_, _) -> [| pure $(return op) <*> $(return left) <*> $(return right) |]+ where+  ambig = fail "Ambiguous infix expression in idiom bracket." applicate x = [| pure $(return x) |] 
− Magic.hs
@@ -1,19 +0,0 @@-{-# LANGUAGE TemplateHaskell #-}--- This stuff has to be in a separate module because of the stage restriction.-module Magic where--import Language.Haskell.TH---- | 'return's 'Just (VarE n)' if 'n' names a variable in scope, or--- 'Nothing' if 'n' is not in scope or is not a variable.-findVar :: Name -> Q (Maybe Exp)-findVar name = recover (return Nothing) $ do-  VarI n _ _ _ <- reify name-  return (Just (VarE n))---- | Returns a Q Exp which expands to Just lookupValueName if lookupValueName--- exists, or Nothing if it doesn't.-maybeVar :: String -> Q Exp-maybeVar s = findVar (mkName s) >>= \e -> case e of-  Nothing -> [| Nothing |]-  Just expr -> [| Just $(return expr) |]
+ README view
@@ -0,0 +1,9 @@+applicative-quoters provides two quasiquoters to be used with+applicative functors: a do-notation-alike, ado, and an attempt to+emulate Conor McBride's idiom brackets.++They are originally taken from Matt Morrow's haskell-src-meta package,+before he disappeared forever and I took up maintainership of it.++However, I no longer maintain it, since it is unused even by me. If+you're interested in keeping it updated, feel free to take over.
applicative-quoters.cabal view
@@ -1,7 +1,7 @@ Cabal-Version: >= 1.6  Name:     applicative-quoters-Version:  0.1.0.5+Version:  0.1.0.6 Category: Language Synopsis: Quasiquoters for idiom brackets and an applicative do-notation @@ -11,33 +11,30 @@     Applicative (and is correspondingly less powerful).  Author:       Matt Morrow-Maintainer:   Ben Millwood <haskell@benmachine.co.uk> Copyright:    (c) Matt Morrow License:      BSD3 License-file: LICENSE +Extra-source-files: ChangeLog README+ Build-type:  Simple-Tested-with: GHC == 6.12.3, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.1+Tested-with: GHC == 7.4.2, GHC == 7.6.1  Library   Exposed-modules:       Control.Applicative.QQ.ADo       Control.Applicative.QQ.Idiom-  Other-modules:-      Magic    Build-depends:-      base >= 4 && < 4.6,-      haskell-src-meta >= 0.2 && < 0.6,-      template-haskell >= 2.4 && < 2.8+      base >= 4 && < 4.7,+      haskell-src-meta >= 0.2 && < 0.7,+      notcpp < 0.3,+      template-haskell >= 2.7 && < 2.9    Extensions:       TemplateHaskell -  -- We disable the missing-fields warning because not only do quoteType-  -- and quoteDec make no sense in this context, we can't initialise them-  -- because they don't exist in TH < 2.5.-  GHC-options: -Wall -fno-warn-missing-fields+  GHC-options: -Wall  Source-Repository head   type:     git