In HaskellDirect, I tried making the example that uses the pcre regular expression
library. I'm not sure these
are bugs but it does make it less than easy to convince my colleagues that Haskell is
a language they ought
to consider using.
1. [dom@lhrtbax pcre]$ make
/usr/local/bin/ghc -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.08/ -L/h
ome/dom/pcre-2.08/ -lpcre -i../../lib -c Main.lhs -o Main.o -osuf o
Main.lhs:10: Could not find valid interface file `RegLib'
Compilation had errors
make: *** [Main.o] Error 1
2. [dom@lhrtbax pcre]$ make RegLib
/usr/local/bin/ghc -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.08/ -L/h
ome/dom/pcre-2.08/ -lpcre -i../../lib -c RegLib.lhs -o RegLib.o -osuf o
RegLib.lhs:10: Could not find valid interface file `Pcre'
Compilation had errors
make: *** [RegLib.o] Error 1
3. [dom@lhrtbax pcre]$ make Pcre
../../src/ihc -fhs-to-c -fno-qualified-names -fexclude-system-includes -cpp -I/h
ome/dom/pcre-2.08/ --asf=Pcre.asf -fvoid-typedef-is-abstract -finline-synonyms -
fout-pointers-are-not-refs -c Pcre.idl -o Pcre.hs
failed
Reason: /usr/include/bits/types.h:38: Parse error on input: unsigned long long
int __u_quad_t;
make: *** [Pcre.hs] Error 1
4. I edited pcre.h and commented out the includes which I guessed (correctly) that
HaskellDirect didn't need.
/* #include <sys/types.h> */
/* #include <stdlib.h> */
5. [dom@lhrtbax pcre]$ make Pcre
../../src/ihc -fhs-to-c -fno-qualified-names -fexclude-system-includes -cpp -I/h
ome/dom/pcre-2.08/ --asf=Pcre.asf -fvoid-typedef-is-abstract -finline-synonyms -
fout-pointers-are-not-refs -c Pcre.idl -o Pcre.hs
/usr/local/bin/ghc -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.08/ -L/h
ome/dom/pcre-2.08/ -lpcre -i../../lib -c Pcre.hs -o Pcre.o -osuf o
Pcre.hs:51: Module `Int' does not export `toInt'
Compilation had errors
make: *** [Pcre.o] Error 1
6. I edited Pcre.hs to import GlaExts
7. [dom@lhrtbax pcre]$ make Pcre
/usr/local/bin/ghc -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.08/ -L/h
ome/dom/pcre-2.08/ -lpcre -i../../lib -c Pcre.hs -o Pcre.o -osuf o
gcc Pcre.o -o Pcre
ghc: module version unchanged at 1
/tmp/ghc29207.hc:258: warning: assignment discards `const' from pointer target t
ype
/tmp/ghc29207.hc:3210: warning: assignment discards `const' from pointer target
type
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
Pcre.o(.text+0x94): undefined reference to `HDirect_free_closure'
Pcre.o(.text+0xe4): undefined reference to `HDirect_writeptr_closure'
... lots of similar errors deleted
Pcre.o(.data+0x2c0): undefined reference to `HDirect_freeString_closure'
Pcre.o(.data+0x2c4): undefined reference to `HDirect_doThenFree_closure'
Pcre.o(.data+0x2c8): undefined reference to `HDirect_unmarshallString_closure'
Pcre.o(.data+0x2e0): undefined reference to `Word_zdfNumWord32_closure'
Pcre.o(.data+0x2e4): undefined reference to `PrelNum_fromInt_closure'
collect2: ld returned 1 exit status
make: *** [Pcre] Error 1
8. I edited RegLib.lhs to import GlaExts and made it getting similar messages to those
in 7.
9 Make now completes.
[dom@lhrtbax pcre]$ make
/usr/local/bin/ghc -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.08/ -L/h
ome/dom/pcre-2.08/ -lpcre -i../../lib -c Main.lhs -o Main.o -osuf o
ghc: module version changed to 1; reason: no old .hi file
/usr/local/bin/ghc -o main -fglasgow-exts -fno-prune-tydecls -I/home/dom/pcre-2.
08/ -L/home/dom/pcre-2.08/ -lpcre -i../../lib Main.o RegLib.o Pcre.o -L..
/../lib -lhdirect
10. Success.
[dom@lhrtbax pcre]$ main ^abc\(\\d+\) abc123
Matching: ^abc(\d+) over: abc123 returns: Just ["abc123","123"]