Skip to content

Instantly share code, notes, and snippets.

@snowmantw
Created January 30, 2014 13:44
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 snowmantw/8708585 to your computer and use it in GitHub Desktop.
Save snowmantw/8708585 to your computer and use it in GitHub Desktop.
Haskell and map/reduce
{-# LANGUAGE UnicodeSyntax #-}
-- Pardon me. Crying for the missing lambda charater on the keybord.
-- Let's construct queries from SQL statements.
makeQueries strs = map λstr → prepare conn str
doQuery qrys = foldl (λresults query → results >> query) (return ()) qrys
-- Do query and get results.
let stmts = [ "INSERT INTO Articles ('Functional JavaScript')"
, "INSERT INTO Gecko VALUES ('30.a1')"
, "DELETE FROM Articles WHERE version='deprecated'"
]
main = execute (doQuery (makeQuery stmts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment