Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created July 14, 2011 20:36
Show Gist options
  • Save ocharles/1083378 to your computer and use it in GitHub Desktop.
Save ocharles/1083378 to your computer and use it in GitHub Desktop.
modelIO :: IO a -> Model a
modelIO action = do
Model $ ReaderT (\_ -> action)
insertBook :: Book -> Model (LoadedCoreEntity Book)
insertBook bookSpec = do
bookGid <- (modelIO randomIO) :: Model UUID
bookRow <- head `fmap` query insertQuery [ toSql "Hello" ]
return $ bookFromRow bookRow
where insertQuery = unlines [ "INSERT INTO book (name)"
, "VALUES (?)"
, "RETURNING *"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment