From 7e90e2dd45c936519b6397a3ac9f8cb481ea6511 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 30 Oct 2008 15:16:37 -0400 Subject: Time MIN/MAX --- lib/top.ur | 8 ++++++++ lib/top.urs | 10 ++++++++++ 2 files changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/top.ur b/lib/top.ur index 0bc345de..d36af3f3 100644 --- a/lib/top.ur +++ b/lib/top.ur @@ -157,3 +157,11 @@ fun oneOrNoRows (tables ::: {{Type}}) (exps ::: {Type}) query q (fn fs _ => return (Some fs)) None + +fun oneRow (tables ::: {{Type}}) (exps ::: {Type}) + (q : sql_query tables exps) [tables ~ exps] = + o <- oneOrNoRows q; + return (case o of + None => error Query returned no rows + | Some r => r) + diff --git a/lib/top.urs b/lib/top.urs index 22cebb16..6e9dda4e 100644 --- a/lib/top.urs +++ b/lib/top.urs @@ -116,3 +116,13 @@ val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type} [[nm] ~ acc] => [nm = $fields] ++ acc) [] tables)) + +val oneRow : tables ::: {{Type}} -> exps ::: {Type} + -> sql_query tables exps + -> fn [tables ~ exps] => + transaction + $(exps + ++ fold (fn nm (fields :: {Type}) acc + [[nm] ~ acc] => + [nm = $fields] ++ acc) + [] tables) -- cgit v1.2.3