Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed more warnings from Lang.Value

  • Loading branch information...
commit 37534773dc72f59c1aa3e33235301ad0ac271dfb 1 parent c5d58d3
Tom Lokhorst authored

Showing 1 changed file with 15 additions and 4 deletions. Show diff stats Hide diff stats

  1. +15 4 src/Lang/Value.hs
19 src/Lang/Value.hs
... ... @@ -1,5 +1,10 @@
1 1 {-# LANGUAGE GADTs #-}
2   -module Lang.Value where
  2 +module Lang.Value
  3 + ( Val (..)
  4 + , fun1
  5 + , fun2
  6 + , fun3
  7 + ) where
3 8
4 9 -- Values have an index for the language and an index for the type of value
5 10 -- being represented.
@@ -13,11 +18,17 @@ data Val l a where
13 18 Name :: String -> Val l a -> Val l a
14 19
15 20 fun1 :: String -> ([String] -> String) -> Val l a -> Val l b
16   -fun1 n f p = (n `Name` Lam (\(Var v) -> Prim f [v])) `App` p
  21 +fun1 n f p = (n `Name` lam (\v -> Prim f [v])) `App` p
17 22
18 23 fun2 :: String -> ([String] -> String) -> Val l a -> Val l b -> Val l c
19   -fun2 n f p0 p1 = (n `Name` Lam (\(Var v) -> Lam (\(Var w) -> Prim f [v, w]))) `App` p0 `App` p1
  24 +fun2 n f p0 p1 = (n `Name` lam (\v -> lam (\w -> Prim f [v, w]))) `App` p0 `App` p1
20 25
21 26 fun3 :: String -> ([String] -> String) -> Val l a -> Val l b -> Val l c -> Val l d
22   -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
  27 +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
  28 +
  29 +lam :: (String -> Val l b) -> Val l (a -> b)
  30 +lam f = Lam g
  31 + where
  32 + g (Var v) = f v
  33 + g _ = error "Lang.Value.lam: wrong constructor"
23 34

0 comments on commit 3753477

Please sign in to comment.
Something went wrong with that request. Please try again.