-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Quasiquoters for idiom brackets and an applicative do-notation
--   
--   Quasiquoters taken from Matt Morrow's haskell-src-meta to implement
--   Conor McBride's idiom brackets, and a do-notation that only requires
--   Applicative (and is correspondingly less powerful).
--   
--   applicative-quoters currently has no maintainer: if it is broken and
--   you want it to be fixed, then fix it!
@package applicative-quoters
@version 0.1.0.8


-- | Idiom brackets. Vixey's idea.
module Control.Applicative.QQ.Idiom

-- | Turns function application into <a>&lt;*&gt;</a>, and puts a
--   <a>pure</a> on the beginning.
--   
--   <pre>
--   [i| subtract [1,2,3] [10,20,30] |]
--   -&gt; pure subtract &lt;*&gt; [1,2,3] &lt;*&gt; [10,20,30]
--   -&gt; [9,19,29,8,18,28,7,17,27]
--   </pre>
--   
--   Does not apply to nested applications:
--   
--   <pre>
--   getZipList [i| subtract (ZipList [1,2,3]) (ZipList [10,20,30]) |]
--   -&gt; getZipList (pure subtract &lt;*&gt; ZipList [1,2,3] &lt;*&gt; ZipList [10,20,30])
--   -&gt; [9,18,27]
--   </pre>
--   
--   Will treat <tt>[i| x `op` y |]</tt> as <tt>[i| op x y |]</tt> as long
--   as neither x nor y are an infix expression. If they are, will likely
--   complain that it doesn't have fixity information (unless
--   haskell-src-meta becomes clever enough to resolve that itself).
i :: QuasiQuoter


-- | Applicative do. Philippa Cowderoy's idea, some explanations due Edward
--   Kmett
--   
--   Pointful version of <a>Language.Haskell.Meta.QQ.Idiom</a>. Note the
--   only expression which has the bound variables in scope is the last
--   one.
--   
--   This lets you work with applicatives without the order of fields in an
--   data constructor becoming such a burden.
--   
--   In a similar role as <a>fail</a> in do notation, if match failures can
--   be expected, the result is an <tt>Applicative f =&gt; f (Maybe
--   a)</tt>, rather than <tt>Applicative f =&gt; f a</tt>, where
--   <tt>a</tt> may be partially defined.
module Control.Applicative.QQ.ADo

-- | Usage:
--   
--   <pre>
--   ghci&gt; [$ado| a &lt;- "foo"; b &lt;- "bar"; (a,b) |]
--   [('f','b'),('f','a'),('f','r'),('o','b'),('o','a'),('o','r'),('o','b'),('o','a'),('o','r')]
--   </pre>
--   
--   <pre>
--   ghci&gt; [$ado| Just a &lt;- [Just 1,Nothing,Just 2]; b &lt;- "fo"; (a,b) |]
--   [Just (1,'f'),Just (1,'o'),Nothing,Nothing,Just (2,'f'),Just (2,'o')]
--   </pre>
--   
--   Notice that the last statement is not of an applicative type, so when
--   translating from monadic do, drop the final <a>return</a>:
--   
--   <pre>
--   (do x &lt;- [1,2,3]; return (x + 1)) == [$ado| x &lt;- [1,2,3]; x + 1 |]
--   </pre>
ado :: QuasiQuoter

-- | Variant of <a>ado</a> that does not implicitly add a Maybe when
--   patterns may fail:
--   
--   <pre>
--   ghci&gt; [$ado'| Just a &lt;- [Just 1,Nothing,Just 2]; b &lt;- "fo"; (a,b) |]
--   [(1,'f'),(1,'o'),*** Exception: &lt;interactive&gt;:...
--   </pre>
ado' :: QuasiQuoter
