blob: 9d57907522730b605cd7be4512644ddef3a946e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
{-# LANGUAGE DataKinds, TemplateHaskell #-}
applicate :: Bool -> [Stmt] -> ExpQ
applicate rawPatterns stmt = do
return $ foldl (\g e -> VarE '(<**>) `AppE` e `AppE` g)
(VarE 'pure `AppE` f')
es
tuple :: Int -> ExpQ
tuple n = do
ns <- replicateM n (newName "x")
lamE [foldr (\x y -> conP '(:) [varP x,y]) wildP ns] (tupE $ map varE ns)
|