Permalink
Browse files

Removed more warnings from Lang.Value

  • Loading branch information...
1 parent c5d58d3 commit 37534773dc72f59c1aa3e33235301ad0ac271dfb @tomlokhorst committed Sep 20, 2011
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/Lang/Value.hs
View
@@ -1,5 +1,10 @@
{-# LANGUAGE GADTs #-}
-module Lang.Value where
+module Lang.Value
+ ( Val (..)
+ , fun1
+ , fun2
+ , fun3
+ ) where
-- Values have an index for the language and an index for the type of value
-- being represented.
@@ -13,11 +18,17 @@ data Val l a where
Name :: String -> Val l a -> Val l a
fun1 :: String -> ([String] -> String) -> Val l a -> Val l b
-fun1 n f p = (n `Name` Lam (\(Var v) -> Prim f [v])) `App` p
+fun1 n f p = (n `Name` lam (\v -> Prim f [v])) `App` p
fun2 :: String -> ([String] -> String) -> Val l a -> Val l b -> Val l c
-fun2 n f p0 p1 = (n `Name` Lam (\(Var v) -> Lam (\(Var w) -> Prim f [v, w]))) `App` p0 `App` p1
+fun2 n f p0 p1 = (n `Name` lam (\v -> lam (\w -> Prim f [v, w]))) `App` p0 `App` p1
fun3 :: String -> ([String] -> String) -> Val l a -> Val l b -> Val l c -> Val l d
-fun3 n f p0 p1 p2 = (n `Name` Lam (\(Var v) -> Lam (\(Var w) -> Lam (\(Var x) -> Prim f [v, w, x])))) `App` p0 `App` p1 `App` p2
+fun3 n f p0 p1 p2 = (n `Name` lam (\v -> lam (\w -> lam (\x -> Prim f [v, w, x])))) `App` p0 `App` p1 `App` p2
+
+lam :: (String -> Val l b) -> Val l (a -> b)
+lam f = Lam g
+ where
+ g (Var v) = f v
+ g _ = error "Lang.Value.lam: wrong constructor"

0 comments on commit 3753477

Please sign in to comment.