applicative-quoters- Quasiquoters for idiom brackets and an applicative do-notation

Safe HaskellNone



Idiom brackets. Vixey's idea.



i :: QuasiQuoterSource

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.