[Hat] Hat bug report: Ambiguous occurrence `List'
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Tue Jun 22 06:55:36 EDT 2004
Fergus Henderson <fjh007 at galois.com> writes:
> > Unfortunately, ghc-6 seems to be rather over-eager to report ambiguous
> > use of identifiers, ...
>
> The Hat.Hat versions are imported unqualified in line 30 of Hat/Foo/List.hs,
> which is "import Hat.Prelude". So I think this is a Hat bug, not a ghc
> bug.
Yes, I realised this shortly after posting, when I discovered the
indirect import route via Hat.Prelude. I am cooking up a relatively
simple hack to fix this. Patch attached. (Hoping you can re-build
the hat-lib from sources.)
> > Ideally we will try to find a fix for this. In the meantime, you
> > can work around the bug either by renaming your own versions of the
> > overlapping identifiers, or always using them qualified (including
> > in export lists).
>
> And including in _implicit_ export lists?
Well, in that case, global renaming might be the better workaround
than identifier qualification.
> Well, I tried that, but the result was another Hat bug: a pattern match
> failure for the following function in src/hattrans/TraceId.hs:
>
> tyClsInfo :: TraceId -> TyCls
> tyClsInfo (TI _ (Just (TyCls tyCls))) = tyCls
>
> Fail: TraceId.hs:152: Non-exhaustive patterns in function tyClsInfo
I couldn't reproduce this bug with the current CVS sources. In any
case, if the other patch works, you shouldn't need to alter your own
sources after all, so hopefully this issue will go away.
Regards,
Malcolm
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/root/hat/src/hatlib/Makefile,v
retrieving revision 1.49
diff -u -r1.49 Makefile
--- Makefile 16 Feb 2004 12:04:22 -0000 1.49
+++ Makefile 22 Jun 2004 10:52:58 -0000
@@ -51,7 +51,7 @@
TRANSSRCS = \
PreludeBuiltin.hs PreludeBasic.hs IOBuiltinTypes.hs \
SystemBuiltinTypes.hs TimeBuiltinTypes.hs DirectoryBuiltinTypes.hs \
- Prelude.hs Char.hs Ratio.hs List.hs Complex.hs Numeric.hs \
+ Char.hs Ratio.hs List.hs Complex.hs Numeric.hs \
Maybe.hs Monad.hs Ix.hs Array.hs IO.hs System.hs \
Locale.hs CPUTime.hs Time.hs Random.hs Directory.hs \
Data/IORef.hs Data/Bool.hs Data/Char.hs Data/Complex.hs Data/Ix.hs \
@@ -82,6 +82,12 @@
TRANSHATS = $(patsubst %, Hat/%, $(TRANSSRCS))
TRANSOBJS = $(patsubst %.hs, $(OBJDIR)/Hat/%.o, $(TRANSSRCS))
+# these Haskell sources are just like TRANSSRCS except we need to
+# fiddle with the .hx file afterwards
+FIDDLESRCS = Prelude.hs
+FIDDLEHATS = $(patsubst %, Hat/%, $(FIDDLESRCS))
+FIDDLEOBJS = $(patsubst %.hs, $(OBJDIR)/Hat/%.o, $(FIDDLESRCS))
+
all: install
install: $(OBJDIR) $(OBJDIRS) $(TARGDIR) $(TARGDIRS) $(TARGET)
@@ -98,7 +104,7 @@
do $(INSTALL) $(OBJDIR)/$$dir/*.hi $(TARGDIR)/$$dir; \
done
clean:
- -rm -rf $(OBJDIR) $(TRANSHATS) Hat/*.hi Hat/Hat.hx \
+ -rm -rf $(OBJDIR) $(TRANSHATS) $(FIDDLEHATS) Hat/*.hi Hat/Hat.hx \
$(patsubst %.hs, %.hx, $(TRANSSRCS))
$(OBJDIR) $(OBJDIRS) $(TARGDIR) $(TARGDIRS):
mkdir -p $@ || $(TRUE)
@@ -112,13 +118,18 @@
$(HC) $(HFLAGS) -c -o $@ Hat/$<
mv $(patsubst %.hs, Hat/%.hi, $<) $(patsubst %.hs, ${OBJDIR}/Hat/%.hi, $<)
+$(FIDDLEOBJS): $(OBJDIR)/Hat/%.o: %.hs
+ $(LOCAL)hat-trans -cpp -P. -I. -trusted -prelude $(CPPFLAGS) $<
+ $(HC) $(HFLAGS) -c -o $@ Hat/$<
+ mv $(patsubst %.hs, Hat/%.hi, $<) $(patsubst %.hs, ${OBJDIR}/Hat/%.hi, $<)
+ $(LOCAL)hat-trans -cpp -DHX -P. -I. -trusted -prelude $(CPPFLAGS) $<
$(COBJS): $(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
# single archive for all object files
-$(TARGET): $(COBJS) $(PLAINOBJS) $(TRANSOBJS)
- $(AR) cr $(TARGET) $(COBJS) $(PLAINOBJS) $(TRANSOBJS)
+$(TARGET): $(COBJS) $(PLAINOBJS) $(FIDDLEOBJS) $(TRANSOBJS)
+ $(AR) cr $(TARGET) $(COBJS) $(PLAINOBJS) $(FIDDLEOBJS) $(TRANSOBJS)
ranlib $(TARGET)
Index: Prelude.hs
===================================================================
RCS file: /home/cvs/root/hat/src/hatlib/Prelude.hs,v
retrieving revision 1.3
diff -u -r1.3 Prelude.hs
--- Prelude.hs 23 Jan 2002 18:22:57 -0000 1.3
+++ Prelude.hs 22 Jun 2004 10:52:58 -0000
@@ -1,3 +1,4 @@
+{-# hat-trans -cpp #-}
-- Wrapper that exports just the stuff normally defined in the
-- Prelude.
-- Has to be transformed into TPreludeTracing.hs and renamed to TPrelude.hs.
@@ -39,7 +40,8 @@
-- These built-in types are defined in the Prelude, but
-- are denoted by built-in syntax, and cannot legally
-- appear in an export list.
--- But they do here, because the transformed module will need the exports
+-- But they do here, because the .hx interface needs the exports.
+#ifdef HX
-- List type:
[]((:), []),
-- Tuple types: up to 15
@@ -52,6 +54,7 @@
()(()),
-- Functions:
(->),
+#endif
Eq((==), (/=)),
Ord(compare, (<), (<=), (>=), (>), max, min),
More information about the Hat
mailing list