Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created February 24, 2020 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdone/8d4cd1f8c12475a6b688a53c6ba71322 to your computer and use it in GitHub Desktop.
Save chrisdone/8d4cd1f8c12475a6b688a53c6ba71322 to your computer and use it in GitHub Desktop.
Applicative TH
applicative :: Q Exp -> [Q Exp] -> Q Exp
applicative cons [] = [| pure $(cons) |]
applicative cons (x:ys) = foldl (\inner y -> [| $(inner) <*> $(y) |]) [|$(cons) <$> $(x)|] ys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment