shithub: MicroHs

Download patch

ref: 61cf95de95be27a6a02e3c67046250946daee4f3
parent: 367493ba64a9b541fbf882af7f3ead26cc6ea787
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Nov 3 20:02:12 EDT 2023

Some Enum instances.

--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
 * Add strict constructors
 * Put on hackage
 * Have compile return a Stats record of timing etc
-* Add overloading
 * Implement deriving
 * Add the possibility to save a compiler cache in a file
   - Add SHA checksumming to the C code
@@ -37,10 +36,9 @@
 * Redo handling of synonym and instance tables.
   - These tables can persist during the compilation
     and only grow
-* Just put exported classes in class export
 * Implement two level tables for instances even in the tricky cases
 * Handle tupled dictionaries better for recursive calls
+* Implement fundeps
 
 Bugs
- * Eq String, Ord String  no synonym expansion
  * Removing [] from prim table
--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
 v4.0
-1313
-((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _129) ((B _12) _1)) _308))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _307))) ((A :10 (((S' P) _2) (((C' _13) _1) _1071))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _126) _12) _118))) ((A :20 (((S' B) _14) (((C' _129) _12) _119))) ((A :21 _1144) ((A :22 ((B _1187) _21)) ((A :23 (((S' _1187) _21) I)) ((A :24 _1114) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1143) ((C _117) _26))) ((A :28 (((C' _27) ((_125 _1157) _98)) ((_117 (_34 _1159)) _97))) ((A :29 ((B ((S _1187) (_34 _1159))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _307)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _308)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _1071)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _1071))) ((A :46 ((C _43) _118)) ((A :47 ((B _120) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _120) _48)) ((A :50 T) ((A :51 ((_124 ((B (B (_115 _50))) ((B ((C' C) _54)) (B P)))) (_128 _51))) ((A :52 (((((_11 _51) ((B (_115 _50)) P)) (_38 _53)) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_115 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_117 _379)) _54)) ((A :56 ((B (_115 _50)) (B (P _1071)))) ((A :57 ((B (_115 _50)) (BK (P _1071)))) ((A :58 ((_115 _50) ((S P) I))) ((A :59 ((B (_115 _50)) ((C (S' P)) I))) ((A :60 ((_102 ((C ((C S') _65)) I)) (_106 _60))) ((A :61 (((_1285 (K ((P (_1294 "False")) (_1294 "True")))) (_1290 _61)) (_1291 _61))) ((A :62 ((_69 _67) _68)) ((A :63 (R _68)) ((A :64 (T _67)) ((A :65 ((P _68) _67)) ((A :66 _68) ((A :67 K) ((A :68 A) ((A :69 P) ((A :70 (T K)) ((A :71 (T A)) ((A :72 (K (noDefault "Bounded.minBound"))) ((A :73 (K (noDefault "Bounded.maxBound"))) ((A :74 ((_102 _1108) _1109)) ((A :75 ((((((((_340 _74) (_349 _75)) _1110) _1111) _1112) _1113) (_354 _75)) (_355 _75))) ((A :76 ((_102 _1118) (_106 _76))) ((A :77 ((((((((_340 _76) _1117) (((C' (C' (_103 _356))) _1117) _360)) (((C' (C' (_104 _356))) _1117) _362)) (((C' (C' (_103 _356))) _1117) _362)) (((C' (C' (_104 _356))) _1117) _362)) (_354 _77)) (_355 _77))) ((A :78 ((_69 (_79 #0)) (_79 #127))) ((A :79 _1119) ((A :80 _1120) ((A :81 (((S' _64) (_1111 #97)) ((C _1111) #122))) ((A :82 (((S' _64) (_1111 #65)) ((C _1111) #90))) ((A :83 (((S' _63) _81) _82)) ((A :84 (((S' _64) (_1111 #48)) ((C _1111) #57))) ((A :85 (((S' _63) _83) _84)) ((A :86 (((S' _64) (_1111 #32)) ((C _1111) #126))) ((A :87 (((S' _63) ((C (_103 _74)) #32)) (((S' _63) ((C (_103 _74)) #9)) ((C (_103 _74)) #10)))) ((A :88 ((S ((S (((S' _64) (_1111 #65)) ((C _1111) #90))) (_68 (((noMatch "lib/Data/Char.hs") #72) #9)))) ((B _79) (((C' (_325 _130)) (((C' (_326 _130)) _80) (_80 #65))) (_80 #97))))) ((A :89 ((S ((S (((S' _64) (_1111 #97)) ((C _1111) #97))) (_68 (((noMatch "lib/Data/Char.hs") #76) #9)))) ((B _79) (((C' (_325 _130)) (((C' (_326 _130)) _80) (_80 #97))) (_80 #65))))) ((A :90 (((_1285 (K ((C ((S ((C ==) #39)) ((B (_117 (_1293 #39))) (((C' _117) ((B _1294) _91)) (_1293 #39))))) (_1294 "'\92&''")))) (_1290 _90)) ((B (_117 (_1293 #34))) (Y ((B (P (_1293 #34))) (((S' C) ((B 
\ No newline at end of file
+1333
+((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _152) ((B _12) _1)) _328))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _327))) ((A :10 (((S' P) _2) (((C' _13) _1) _1091))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _149) _12) _140))) ((A :20 (((S' B) _14) (((C' _152) _12) _141))) ((A :21 _1164) ((A :22 ((B _1207) _21)) ((A :23 (((S' _1207) _21) I)) ((A :24 _1134) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1163) ((C _139) _26))) ((A :28 (((C' _27) ((_148 _1177) _98)) ((_139 (_34 _1179)) _97))) ((A :29 ((B ((S _1207) (_34 _1179))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _327)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _328)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _1091)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _1091))) ((A :46 ((C _43) _140)) ((A :47 ((B _142) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _142) _48)) ((A :50 T) ((A :51 ((_147 ((B (B (_137 _50))) ((B ((C' C) _54)) (B P)))) (_151 _51))) ((A :52 (((((_11 _51) ((B (_137 _50)) P)) (_38 _53)) ((B (B (_137 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_137 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_139 _399)) _54)) ((A :56 ((B (_137 _50)) (B (P _1091)))) ((A :57 ((B (_137 _50)) (BK (P _1091)))) ((A :58 ((_137 _50) ((S P) I))) ((A :59 ((B (_137 _50)) ((C (S' P)) I))) ((A :60 ((_124 ((C ((C S') _65)) I)) (_128 _60))) ((A :61 (((_1305 (K ((P (_1314 "False")) (_1314 "True")))) (_1310 _61)) (_1311 _61))) ((A :62 ((_69 _67) _68)) ((A :63 (R _68)) ((A :64 (T _67)) ((A :65 ((P _68) _67)) ((A :66 _68) ((A :67 K) ((A :68 A) ((A :69 P) ((A :70 (T K)) ((A :71 (T A)) ((A :72 (K (noDefault "Bounded.minBound"))) ((A :73 (K (noDefault "Bounded.maxBound"))) ((A :74 ((_124 _1128) _1129)) ((A :75 ((((((((_360 _74) (_369 _75)) _1130) _1131) _1132) _1133) (_374 _75)) (_375 _75))) ((A :76 ((_124 _1138) (_128 _76))) ((A :77 ((((((((_360 _76) _1137) (((C' (C' (_125 _376))) _1137) _380)) (((C' (C' (_126 _376))) _1137) _382)) (((C' (C' (_125 _376))) _1137) _382)) (((C' (C' (_126 _376))) _1137) _382)) (_374 _77)) (_375 _77))) ((A :78 ((_69 (_79 #0)) (_79 #127))) ((A :79 _1139) ((A :80 _1140) ((A :81 (((S' _64) (_1131 #97)) ((C _1131) #122))) ((A :82 (((S' _64) (_1131 #65)) ((C _1131) #90))) ((A :83 (((S' _63) _81) _82)) ((A :84 (((S' _64) (_1131 #48)) ((C _1131) #57))) ((A :85 (((S' _63) _83) _84)) ((A :86 (((S' _64) (_1131 #32)) ((C _1131) #126))) ((A :87 (((S' _63) ((C (_125 _74)) #32)) (((S' _63) ((C (_125 _74)) #9)) ((C (_125 _74)) #10)))) ((A :88 ((S ((S (((S' _64) (_1131 #65)) ((C _1131) #90))) (_68 (((noMatch "lib/Data/Char.hs") #72) #9)))) ((B _79) (((C' (_345 _153)) (((C' (_346 _153)) _80) (_80 #65))) (_80 #97))))) ((A :89 ((S ((S (((S' _64) (_1131 #97)) ((C _1131) #97))) (_68 (((noMatch "lib/Data/Char.hs") #76) #9)))) ((B _79) (((C' (_345 _153)) (((C' (_346 _153)) _80) (_80 #97))) (_80 #65))))) ((A :90 (((_1305 (K ((C ((S ((C ==) #39)) ((B (_139 (_1313 #39))) (((C' _139) ((B _1314) _91)) (_1313 #39))))) (_1314 "'\92&''")))) (_1310 _90)) ((B (_139 (_1313 #34))) (Y ((B (P (_1313 #34))) (((S' C) ((B 
\ No newline at end of file
--- a/lib/Data/Double.hs
+++ b/lib/Data/Double.hs
@@ -26,7 +26,10 @@
 
 instance Fractional Double where
   (/) = primDoubleDiv
-  fromRational x = fromInteger (numerator x) `primDoubleDiv` fromInteger (denominator x)  -- XXX This isn't right
+  -- This version of fromRational can go horribly wrong
+  -- if the integers are bigger than can be represented in a Double.
+  -- It'll do for now.
+  fromRational x = fromInteger (numerator x) `primDoubleDiv` fromInteger (denominator x)
 
 instance Eq Double where
   (==) = primDoubleEQ
--- /dev/null
+++ b/lib/Data/Enum.hs
@@ -1,0 +1,70 @@
+module Data.Enum(module Data.Enum) where
+import Primitives
+import Control.Error
+import Data.Bool
+import Data.Char_Type
+import Data.Bounded
+import Data.Function
+import Data.Int
+import Data.List
+import Data.Num
+import Data.Ord
+
+class Enum a where
+  succ           :: a -> a
+  pred           :: a -> a
+  toEnum         :: Int -> a
+  fromEnum       :: a -> Int
+
+  enumFrom       :: a -> [a]
+  enumFromThen   :: a -> a -> [a]
+  enumFromTo     :: a -> a -> [a]
+  enumFromThenTo :: a -> a -> a -> [a]
+
+  succ                   = toEnum . (+ 1) . fromEnum
+  pred                   = toEnum . (subtract 1) . fromEnum
+  enumFrom x             = map toEnum [fromEnum x ..]
+  enumFromThen x y       = map toEnum [fromEnum x, fromEnum y ..]
+  enumFromTo x y         = map toEnum [fromEnum x .. fromEnum y]
+  enumFromThenTo x1 x2 y = map toEnum [fromEnum x1, fromEnum x2 .. fromEnum y]
+
+boundedEnumFrom :: forall a . (Enum a, Bounded a) => a -> [a]
+boundedEnumFrom n = map toEnum [fromEnum n .. fromEnum (maxBound `asTypeOf` n)]
+
+boundedEnumFromThen :: forall a . (Enum a, Bounded a) => a -> a -> [a]
+boundedEnumFromThen n1 n2
+  | i_n2 >= i_n1  = map toEnum [i_n1, i_n2 .. fromEnum (maxBound `asTypeOf` n1)]
+  | otherwise     = map toEnum [i_n1, i_n2 .. fromEnum (minBound `asTypeOf` n1)]
+  where
+    i_n1 = fromEnum n1
+    i_n2 = fromEnum n2
+
+-- This instance is difficult to put in Data.Int,
+-- so it gets to live here.
+instance Enum Int where
+  succ x = x + 1
+  pred x = x - 1
+  toEnum x = x
+  fromEnum x = x
+  enumFrom n = n : enumFrom (n+1)
+  enumFromThen n m = from n
+    where d = m - n
+          from i = i : from (i+d)
+  enumFromTo l h = takeWhile (<= h) (enumFrom l)
+  enumFromThenTo l m h =
+    if m > l then
+      takeWhile (<= h) (enumFromThen l m)
+    else
+      takeWhile (>= h) (enumFromThen l m)
+
+-- Likewise for Bool
+instance Enum Bool where
+  fromEnum False = 0
+  fromEnum True  = 1
+  toEnum 0 = False
+  toEnum 1 = True
+  toEnum _ = error "Enum.Bool.toEnum: bad arg"
+
+instance Enum Char where
+  fromEnum = primOrd
+  toEnum   = primChr
--- a/lib/Data/Function.hs
+++ b/lib/Data/Function.hs
@@ -34,3 +34,6 @@
 infixl 0 `on`
 on :: forall a b c . (a -> a -> b) -> (c -> a) -> (c -> c -> b)
 on op sel x y = op (sel x) (sel y)
+
+asTypeOf :: forall a . a -> a -> a
+asTypeOf = const
--- a/lib/Data/Integer.hs
+++ b/lib/Data/Integer.hs
@@ -13,6 +13,7 @@
 import Control.Error
 import Data.Bool
 import Data.Char
+import Data.Enum
 import Data.Eq
 import Data.Function
 import Data.Int
@@ -77,6 +78,24 @@
 
 instance Real Integer where
   toRational i = _integerToRational i
+
+instance Enum Integer where
+  succ x = x + 1
+  pred x = x - 1
+  toEnum x = _intToInteger x
+  fromEnum x = _integerToInt x
+  enumFrom n = n : enumFrom (n+1)
+  enumFromThen n m = from n
+    where d = m - n
+          from i = i : from (i+d)
+  enumFromTo l h = takeWhile (<= h) (enumFrom l)
+  enumFromThenTo l m h =
+    if m > l then
+      takeWhile (<= h) (enumFromThen l m)
+    else
+      takeWhile (>= h) (enumFromThen l m)
+
+------------------------------------------------
 
 isZero :: Integer -> Bool
 isZero (I _ ds) = null ds
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -249,24 +249,6 @@
 elemBy :: forall a . (a -> a -> Bool) -> a -> [a] -> Bool
 elemBy eq a = any (eq a)
 
-enumFrom :: Int -> [Int]
-enumFrom n = n : enumFrom (n+1)
-
-enumFromThen :: Int -> Int -> [Int]
-enumFromThen n m = from n
-  where d = m - n
-        from i = i : from (i+d)
-
-enumFromTo :: Int -> Int -> [Int]
-enumFromTo l h = takeWhile (<= h) (enumFrom l)
-
-enumFromThenTo :: Int -> Int -> Int -> [Int]
-enumFromThenTo l m h =
-  if m > l then
-    takeWhile (<= h) (enumFromThen l m)
-  else
-    takeWhile (>= h) (enumFromThen l m)
-
 find :: forall a . (a -> Bool) -> [a] -> Maybe a
 find p [] = Nothing
 find p (x:xs) = if p x then Just x else find p xs
--- a/lib/Prelude.hs
+++ b/lib/Prelude.hs
@@ -5,9 +5,11 @@
   module Control.Error,
   module Control.Monad,
   module Data.Bool,
+  module Data.Bounded,
   module Data.Char,
   module Data.Double,
   module Data.Either,
+  module Data.Enum,
   module Data.Eq,
   module Data.Fractional,
   module Data.Function,
@@ -19,6 +21,7 @@
   module Data.Maybe,
   module Data.Num,
   module Data.Ord,
+  module Data.Real,
   module Data.Tuple,
   module System.IO,
   module Text.Show,
@@ -25,14 +28,16 @@
   module Text.String,
   --Ymodule Primitives,
   ) where
---Yimport Primitives(fromInteger, fromRational, ifThenElse)
+--Yimport Primitives(ifThenElse)
 import Control.Applicative
 import Control.Error
 import Control.Monad
 import Data.Bool
+import Data.Bounded
 import Data.Char
 import Data.Double
 import Data.Either
+import Data.Enum
 import Data.Eq
 import Data.Fractional
 import Data.Function
@@ -44,6 +49,7 @@
 import Data.Maybe
 import Data.Num
 import Data.Ord
+import Data.Real
 import Data.Tuple
 import System.IO
 import Text.Show
--- a/src/MicroHs/Desugar.hs
+++ b/src/MicroHs/Desugar.hs
@@ -1,6 +1,6 @@
 -- Copyright 2023 Lennart Augustsson
 -- See LICENSE file for full license.
-{-# OPTIONS_GHC -Wno-type-defaults -Wno-incomplete-uni-patterns -Wno-unused-imports -Wno-dodgy-imports #-}
+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns -Wno-unused-imports -Wno-dodgy-imports #-}
 module MicroHs.Desugar(
   desugar,
   LDef, showLDefs,
@@ -35,13 +35,13 @@
     Data _ cs ->
       let
         f i = mkIdent ("$f" ++ show i)
-        fs = [f i | (i, _) <- zip (enumFrom 0) cs]
+        fs = [f i | (i, _) <- zip [0::Int ..] cs]
         dsConstr i (Constr c ets) =
           let
             ts = either id (map snd) ets
-            xs = [mkIdent ("$x" ++ show j) | (j, _) <- zip (enumFrom 0) ts]
+            xs = [mkIdent ("$x" ++ show j) | (j, _) <- zip [0::Int ..] ts]
           in (qualIdent mn c, lams xs $ lams fs $ apps (Var (f i)) (map Var xs))
-      in  zipWith dsConstr (enumFrom 0) cs
+      in  zipWith dsConstr [0::Int ..] cs
     Newtype _ (Constr c _) -> [ (qualIdent mn c, Lit (LPrim "I")) ]
     Type _ _ -> []
     Fcn f eqns -> [(f, dsEqns (getSLocIdent f) eqns)]
@@ -214,7 +214,7 @@
         case getTupleConstr ci of
           Just n ->
             let
-              xs = [mkIdent ("x" ++ show i) | i <- enumFromTo 1 n ]
+              xs = [mkIdent ("x" ++ show i) | i <- [1 .. n] ]
               body = mkTupleE $ map Var xs
             in foldr Lam body xs
           Nothing -> Var (conIdent c)
@@ -228,7 +228,7 @@
 mkTupleSelE :: Int -> Int -> Exp -> Exp
 mkTupleSelE m n tup =
   let
-    xs = [mkIdent ("x" ++ show i) | i <- enumFromTo 1 n ]
+    xs = [mkIdent ("x" ++ show i) | i <- [1 .. n] ]
   in App tup (foldr Lam (Var (xs !! m)) xs)
 
 -- Handle special syntax for lists and tuples
@@ -271,7 +271,7 @@
 apps f = foldl App f
 
 newVars :: String -> [Ident] -> [Ident]
-newVars s is = deleteAllsBy (==) [ mkIdent (s ++ show i) | i <- enumFrom 1 ] is
+newVars s is = deleteAllsBy (==) [ mkIdent (s ++ show i) | i <- [1::Int ..] ] is
 
 newVar :: [Ident] -> Ident
 newVar = head . newVars "$q"
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -1238,6 +1238,7 @@
       mn <- gets moduleName
       teqns <- tcEqns tt eqns
 --      traceM ("tcDefValue: after " ++ showEDefs [adef, Fcn i teqns])
+      -- Defaulting should be done here
       checkConstraints
       return $ Fcn (qualIdent mn i) teqns
     ForImp ie i t -> do
@@ -2194,7 +2195,7 @@
     Nothing ->
       case M.lookup i genv of
         Just [e] -> Right e
-        Just es  -> Left $ "ambiguous " ++ msg ++ ": " ++ showIdent i ++ " " ++ showListS showExpr [ e | Entry e _ <- es ]
+        Just es  -> Left $ "ambiguous " ++ msg ++ ": " ++ showIdent i ++ " " ++ showListS (showIdent . getAppCon) [ e | Entry e _ <- es ]
         Nothing  -> Left $ "undefined " ++ msg ++ ": " ++ showIdent i
                            -- ++ "\n" ++ show lenv ++ "\n" ++ show genv
 
--- a/tests/Enum.hs
+++ b/tests/Enum.hs
@@ -3,10 +3,10 @@
 
 main :: IO ()
 main = do
-  putStrLn $ show [1 .. 5]
-  putStrLn $ show [1 .. 1]
-  putStrLn $ show [1 .. 0]
-  putStrLn $ show [1,3 .. 10]
-  putStrLn $ show [1, -1 .. -5]
-  putStrLn $ show $ take 5 [1 ..]
-  putStrLn $ show $ take 5 [1,3 ..]
+  putStrLn $ show [1::Int .. 5]
+  putStrLn $ show [1::Int .. 1]
+  putStrLn $ show [1::Int .. 0]
+  putStrLn $ show [1,3::Int .. 10]
+  putStrLn $ show [1::Int, -1 .. -5]
+  putStrLn $ show $ take 5 [1::Int ..]
+  putStrLn $ show $ take 5 [1,3::Int ..]
--- a/tests/MutRec.hs
+++ b/tests/MutRec.hs
@@ -5,4 +5,4 @@
 main = do
   let even i = if i == 0 then True  else odd  (i - 1)
       odd  i = if i == 0 then False else even (i - 1)
-  putStrLn $ show $ map even [1 .. 5] ++ map odd [1 .. 5]
+  putStrLn $ show $ map even [1::Int .. 5] ++ map odd [1 .. 5]
--