# HG changeset patch
# Parent aadfc1a138d8a04788a43767389deb77276c9066
Standard library additions: Option.unsafeGet, Basis.exp

diff -r aadfc1a138d8 lib/ur/basis.urs
--- a/lib/ur/basis.urs	Mon Oct 22 01:49:22 2012 +0400
+++ b/lib/ur/basis.urs	Sun Nov 18 07:25:57 2012 -0600
@@ -42,6 +42,7 @@
 val times : t ::: Type -> num t -> t -> t -> t
 val divide : t ::: Type -> num t -> t -> t -> t
 val mod : t ::: Type -> num t -> t -> t -> t
+val exp : t ::: Type -> num t -> t -> t -> t
 val num_int : num int
 val num_float : num float
 
diff -r aadfc1a138d8 lib/ur/option.ur
--- a/lib/ur/option.ur	Mon Oct 22 01:49:22 2012 +0400
+++ b/lib/ur/option.ur	Sun Nov 18 07:25:57 2012 -0600
@@ -49,3 +49,8 @@
     case o of
         None => x
       | Some v => v
+
+fun unsafeGet [a] (o : option a) =
+    case o of
+        None   => error <xml>Option.unsafeGet: encountered None</xml>
+      | Some v => v
diff -r aadfc1a138d8 lib/ur/option.urs
--- a/lib/ur/option.urs	Mon Oct 22 01:49:22 2012 +0400
+++ b/lib/ur/option.urs	Sun Nov 18 07:25:57 2012 -0600
@@ -12,3 +12,4 @@
 val bind : a ::: Type -> b ::: Type -> (a -> option b) -> t a -> t b
 
 val get : a ::: Type -> a -> option a -> a
+val unsafeGet : a ::: Type -> option a -> a
diff -r aadfc1a138d8 src/monoize.sml
--- a/src/monoize.sml	Mon Oct 22 01:49:22 2012 +0400
+++ b/src/monoize.sml	Sun Nov 18 07:25:57 2012 -0600
@@ -191,7 +191,8 @@
                                      ("Minus", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                                      ("Times", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                                      ("Div", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
-                                     ("Mod", (L'.TFun (t, (L'.TFun (t, t), loc)), loc))],
+                                     ("Mod", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
+				     ("Exp", (L'.TFun (t, (L'.TFun (t, t), loc)), loc))],
                          loc)
                     end
                   | L.CApp ((L.CFfi ("Basis", "ord"), _), t) =>
@@ -791,15 +792,17 @@
                          ("Minus", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                          ("Times", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                          ("Div", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
-                         ("Mod", (L'.TFun (t, (L'.TFun (t, t), loc)), loc))], loc)
-        fun numEx (t, zero, neg, plus, minus, times, dv, md) =
+                         ("Mod", (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
+			 ("Exp", (L'.TFun (t, (L'.TFun (t, t), loc)), loc))], loc)
+        fun numEx (t, zero, neg, plus, minus, times, dv, md, ex) =
             ((L'.ERecord [("Zero", (L'.EPrim zero, loc), t),
                           ("Neg", neg, (L'.TFun (t, t), loc)),
                           ("Plus", plus, (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                           ("Minus", minus, (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                           ("Times", times, (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
                           ("Div", dv, (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
-                          ("Mod", md, (L'.TFun (t, (L'.TFun (t, t), loc)), loc))], loc), fm)
+                          ("Mod", md, (L'.TFun (t, (L'.TFun (t, t), loc)), loc)),
+                          ("Exp", ex, (L'.TFun (t, (L'.TFun (t, t), loc)), loc))], loc), fm)
 
         fun ordTy t =
             (L'.TRecord [("Lt", (L'.TFun (t, (L'.TFun (t, (L'.TFfi ("Basis", "bool"), loc)), loc)), loc)),
@@ -1029,6 +1032,13 @@
                 ((L'.EAbs ("r", numTy t, (L'.TFun (t, (L'.TFun (t, t), loc)), loc),
                            (L'.EField ((L'.ERel 0, loc), "Mod"), loc)), loc), fm)
             end
+	  | L.ECApp ((L.EFfi ("Basis", "exp"), _), t) =>
+            let
+                val t = monoType env t
+            in
+                ((L'.EAbs ("r", numTy t, (L'.TFun (t, (L'.TFun (t, t), loc)), loc),
+                           (L'.EField ((L'.ERel 0, loc), "Exp"), loc)), loc), fm)
+            end
           | L.EFfi ("Basis", "num_int") =>
             let
                 fun intBin s =
@@ -1047,7 +1057,9 @@
                        intBin "-",
                        intBin "*",
                        intBin "/",
-                       intBin "%")
+                       intBin "%",
+                       intBin "powl"
+                       )
             end
           | L.EFfi ("Basis", "num_float") =>
             let
@@ -1067,7 +1079,9 @@
                        floatBin "-",
                        floatBin "*",
                        floatBin "fdiv",
-                       floatBin "fmod")
+                       floatBin "fmod",
+                       floatBin "powf"
+		       )
             end
 
           | L.ECApp ((L.EFfi ("Basis", "lt"), _), t) =>
