|
|
Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: Template Haskell - msg#00106
List: lang.haskell.glasgow.bugs
Hi,
i've got a problem with the function recover in Template Haskell:
I'd like to check, if a function is already implemented. My idea is to
call reify with the functionname. But reify throws an error if the name is
not in scope. So I wanted to use "recover", but it doesn't work like
expected:
y = $(recover (return (LitE (IntegerL 1)))
(reify (mkName ("ola")) >> return (LitE (IntegerL 2))))
The compilation failed: `ola' is not in scope at a reify
In the definition of `y'
I thought the value of y would be 1, if "ola" is not in scope and 2
otherwise.
And even this doesn't work (the compilation failed):
x = $(recover (return (LitE (IntegerL 1)))
(report True "error" >> return (LitE (IntegerL 2))))
Is there a bug in recover?
Melanie Bargstädt
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Build fail on MacOSX 1.4.5
Hello,
been trying tobuild ghc from scratch (I'd like to fiddle with its code).
I work on a PowerBook Mac under version 1.4.5 of MacOSX and
the compile failed on the 1.4.2 sources from the haskell.org/ghc
site. Strangely, this seemed also to be a bug on MacOSX 1.3.9
and a bug tracking report told me it was fixed. So what happened here?
Can anybody help me out? Please reply to this message, since I am not
a member of this group (yet).
The output of the compiler is this:
...lots of stuf omitted...
------------------------------------------------------------------------
/usr/local/bin/ghc -H16m -O -istage1/utils -istage1/basicTypes -
istage1/types -istage1/hsSyn -istage1/prelude -istage1/rename -
istage1/typecheck -istage1/deSugar -istage1/coreSyn -istage1/
specialise -istage1/simplCore -istage1/stranal -istage1/stgSyn -
istage1/simplStg -istage1/codeGen -istage1/main -istage1/
profiling -istage1/parser -istage1/cprAnalysis -istage1/compMan -
istage1/ndpFlatten -istage1/iface -istage1/cmm -istage1/nativeGen
-istage1/ghci -Istage1 -DGHCI -package template-haskell -package
readline -DUSE_READLINE -cpp -fglasgow-exts -fno-generics -Rghc-
timing -I. -IcodeGen -InativeGen -Iparser -package unix -ignore-
package lang -recomp -Rghc-timing -H16M '-#include "hschooks.h"' -
i../lib/compat -ignore-package Cabal -c utils/PrimPacked.lhs -o
stage1/utils/PrimPacked.o -ohi stage1/utils/PrimPacked.hi
utils/PrimPacked.lhs:250:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:254:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:257:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:260:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:263:0:
Warning: foreign declaration uses deprecated non-standard syntax
In file included from /tmp/ghc29849.hc:5:
/usr/local/lib/ghc-6.4.1/include/HsUnix.h: In function
'__hsunix_rtldNext':
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: 'RTLD_NEXT'
undeclared (first use in this function)
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: (Each
undeclared identifier is reported only once
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: for each
function it appears in.)
/usr/local/lib/ghc-6.4.1/include/HsUnix.h: In function
'__hsunix_rtldDefault':
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:107: error: 'RTLD_DEFAULT'
undeclared (first use in this function)
<<ghc: 49082080 bytes, 10 GCs, 1539742/2981452 avg/max bytes
residency (2 samples), 17M in use, 0.13 INIT (0.00 elapsed), 0.54 MUT
(1.13 elapsed), 0.25 GC (0.36 elapsed) :ghc>>
make[2]: *** [stage1/utils/PrimPacked.o] Error 1
make[1]: *** [all] Error 1
make: *** [build] Error 1
cheers,
Jur(riaan Hage)
Next Message by Date:
click to view message preview
Error in shutdownHaskell() in Win32 DLL
If an exception occurs in a Windows DLL produced by GHC,
the following error message appears:
ghcDll: internal error: too many hs_exit()s
Please report this as a bug to glasgow-haskell-bugs@xxxxxxxxxxx,
or http://www.sourceforge.net/projects/ghc/
How to reproduce
----------------
1. Make a Haskell DLL using the enclosed Dll.hs and dllMain.c, e.g.
ghc -c Dll.hs -fglasgow-exts
ghc -c dllMain.c
ghc --mk-dll -o test.dll Dll.o Dll_stub.o dllMain.o
2. Generate an export library for the DLL, e.g.
lib /DEF:test.def /MACHINE:x86 /OUT:test.lib
3. Compile the executable with Visual C++ and run it.
cl -c testdll.cpp
link testdll.obj test.lib /OUT:testdll.exe
testdll.exe
Note: if I comment out the shutdownHaskell() call from dllMain.c
(the line marked with /***/), it works fine.
Kind regards,
Cyril
--- Dll.hs ---
module Dll (test) where
foreign export ccall test :: IO ()
test = error "Exception occurred"
--- dllMain.c ---
#include <windows.h>
#include <Rts.h>
extern void __stginit_Dll(void);
static char* args[] = { "ghcDll", NULL };
BOOL
STDCALL
DllMain
( HANDLE hModule
, DWORD reason
, void* reserved
)
{
if (reason == DLL_PROCESS_ATTACH) {
startupHaskell(1, args, __stginit_Dll);
return TRUE;
} else if (reason == DLL_PROCESS_DETACH) {
/***/ shutdownHaskell();
}
return TRUE;
}
--- test.def ---
EXPORTS
test
--- testdll.cpp ---
extern "C" void test();
int main() {
test();
return 0;
}
Previous Message by Thread:
click to view message preview
Build fail on MacOSX 1.4.5
Hello,
been trying tobuild ghc from scratch (I'd like to fiddle with its code).
I work on a PowerBook Mac under version 1.4.5 of MacOSX and
the compile failed on the 1.4.2 sources from the haskell.org/ghc
site. Strangely, this seemed also to be a bug on MacOSX 1.3.9
and a bug tracking report told me it was fixed. So what happened here?
Can anybody help me out? Please reply to this message, since I am not
a member of this group (yet).
The output of the compiler is this:
...lots of stuf omitted...
------------------------------------------------------------------------
/usr/local/bin/ghc -H16m -O -istage1/utils -istage1/basicTypes -
istage1/types -istage1/hsSyn -istage1/prelude -istage1/rename -
istage1/typecheck -istage1/deSugar -istage1/coreSyn -istage1/
specialise -istage1/simplCore -istage1/stranal -istage1/stgSyn -
istage1/simplStg -istage1/codeGen -istage1/main -istage1/
profiling -istage1/parser -istage1/cprAnalysis -istage1/compMan -
istage1/ndpFlatten -istage1/iface -istage1/cmm -istage1/nativeGen
-istage1/ghci -Istage1 -DGHCI -package template-haskell -package
readline -DUSE_READLINE -cpp -fglasgow-exts -fno-generics -Rghc-
timing -I. -IcodeGen -InativeGen -Iparser -package unix -ignore-
package lang -recomp -Rghc-timing -H16M '-#include "hschooks.h"' -
i../lib/compat -ignore-package Cabal -c utils/PrimPacked.lhs -o
stage1/utils/PrimPacked.o -ohi stage1/utils/PrimPacked.hi
utils/PrimPacked.lhs:250:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:254:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:257:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:260:0:
Warning: foreign declaration uses deprecated non-standard syntax
utils/PrimPacked.lhs:263:0:
Warning: foreign declaration uses deprecated non-standard syntax
In file included from /tmp/ghc29849.hc:5:
/usr/local/lib/ghc-6.4.1/include/HsUnix.h: In function
'__hsunix_rtldNext':
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: 'RTLD_NEXT'
undeclared (first use in this function)
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: (Each
undeclared identifier is reported only once
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:103: error: for each
function it appears in.)
/usr/local/lib/ghc-6.4.1/include/HsUnix.h: In function
'__hsunix_rtldDefault':
/usr/local/lib/ghc-6.4.1/include/HsUnix.h:107: error: 'RTLD_DEFAULT'
undeclared (first use in this function)
<<ghc: 49082080 bytes, 10 GCs, 1539742/2981452 avg/max bytes
residency (2 samples), 17M in use, 0.13 INIT (0.00 elapsed), 0.54 MUT
(1.13 elapsed), 0.25 GC (0.36 elapsed) :ghc>>
make[2]: *** [stage1/utils/PrimPacked.o] Error 1
make[1]: *** [all] Error 1
make: *** [build] Error 1
cheers,
Jur(riaan Hage)
Next Message by Thread:
click to view message preview
Error in shutdownHaskell() in Win32 DLL
If an exception occurs in a Windows DLL produced by GHC,
the following error message appears:
ghcDll: internal error: too many hs_exit()s
Please report this as a bug to glasgow-haskell-bugs@xxxxxxxxxxx,
or http://www.sourceforge.net/projects/ghc/
How to reproduce
----------------
1. Make a Haskell DLL using the enclosed Dll.hs and dllMain.c, e.g.
ghc -c Dll.hs -fglasgow-exts
ghc -c dllMain.c
ghc --mk-dll -o test.dll Dll.o Dll_stub.o dllMain.o
2. Generate an export library for the DLL, e.g.
lib /DEF:test.def /MACHINE:x86 /OUT:test.lib
3. Compile the executable with Visual C++ and run it.
cl -c testdll.cpp
link testdll.obj test.lib /OUT:testdll.exe
testdll.exe
Note: if I comment out the shutdownHaskell() call from dllMain.c
(the line marked with /***/), it works fine.
Kind regards,
Cyril
--- Dll.hs ---
module Dll (test) where
foreign export ccall test :: IO ()
test = error "Exception occurred"
--- dllMain.c ---
#include <windows.h>
#include <Rts.h>
extern void __stginit_Dll(void);
static char* args[] = { "ghcDll", NULL };
BOOL
STDCALL
DllMain
( HANDLE hModule
, DWORD reason
, void* reserved
)
{
if (reason == DLL_PROCESS_ATTACH) {
startupHaskell(1, args, __stginit_Dll);
return TRUE;
} else if (reason == DLL_PROCESS_DETACH) {
/***/ shutdownHaskell();
}
return TRUE;
}
--- test.def ---
EXPORTS
test
--- testdll.cpp ---
extern "C" void test();
int main() {
test();
return 0;
}
|
|