Re: Eval in Haskell
[Moving to cafe, this is only barely Haskell-related.] On Sun, Jun 01, 2003 at 04:16:36PM -0700, [EMAIL PROTECTED] wrote: Eval of the kind let x = 1 in eval x is plainly an abomination. I agree, though not because of the optimization issues but rather as a matter of principle: a closed variable should be _closed_, it should not be visible to anything but the body of the let-expression that binds it. And an externally acquired eval-able expression is definitely anything but. Nevertheless, this abomination is supported even by some scheme implementations: guile (define local-environment (procedure-syntax (lambda (exp env) env))) guile (define (eval-where-x-bound exp) ... (let ((x 'foo)) (local-eval exp (local-environment guile (eval-where-x-bound '(list 'x x)) (x foo) Incidentally, restricting eval to top-level or standard bindings is not a significant limitation. It is, in general, a very good practice to apply eval to closed expressions only. This depends entirely on what you want to achive with eval, so I don't think the in general is justified. If you just want to evaluate closed expressions whose results are printable and readable, then you really just have an embedded interpreter which happens to read the same language as your source code. On the other hand, it is common for perl programs and especially shell scripts to eval configuration files with the explicit purpose that the configuration file may alter variables which are bound in the main program. For such usage, it is essential that the main program and the evaled file access the same enviroment. (Naturally a configuration file shouldn't be allowed to mess with _everything_ in the main program, but I don't think perl allows detailed adjustment of the bindings in the environment. Some schemes do, though.) Lauri Alanko [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Eval in Haskell
In article [EMAIL PROTECTED], Lauri Alanko [EMAIL PROTECTED] wrote: Nevertheless, this abomination is supported even by some scheme implementations: guile (define local-environment (procedure-syntax (lambda (exp env) env))) guile (define (eval-where-x-bound exp) ... (let ((x 'foo)) (local-eval exp (local-environment guile (eval-where-x-bound '(list 'x x)) (x foo) Guile seems to be a bit sloppy in general. I think it just keeps a dictionary of symbol bindings and passes it around at runtime. guile (eval '(define b 5)) guile b 5 -- Ashley Yakeley, Seattle WA ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Is my question bad ?
Karl M Syring wrote: Antoine Utonium wrote on Sat, 31 May 2003 13:29:09 +0200: I recently asked you who knows how to link haskell-made code to C apps, or call haskell code from C code, or encapsulate, traduce, Haskell code in C code. I just want to use haskell when I need advanced algorithms, C for I/O, and GUI (under windows).. If my question has been answered yet, or if my english is too bad, please say me, or give me links to answers. Thanks. Antoine Utonium wrote: Everything is in the title. I like "simplicity" of Haskell and would like to use what i write in my c/c++ programs. Thanks a lot by advance. I guess, there are people who have tried, but failed :-) The easiest way would be to make a COM server in Haskell. You should have a look at the HDirect sources, where there are some examples. Generally using a COM dll from Haskell seems to work, while the other way round seems to be problematic. Karl M. Syring If you are using GHC, you could compile your ".hs" to a Haskell C (".hc") which is a C file, this way: ghc -C myfile.hs There are also other options like compiling an ".o" but I've never tried'em. Wish you luck. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Is my question bad ?
Karl M Syring wrote: Antoine Utonium wrote on Sat, 31 May 2003 13:29:09 +0200: I recently asked you who knows how to link haskell-made code to C apps, or call haskell code from C code, or encapsulate, traduce, Haskell code in C code. I just want to use haskell when I need advanced algorithms, C for I/O, and GUI (under windows).. If my question has been answered yet, or if my english is too bad, please say me, or give me links to answers. Thanks. Antoine Utonium wrote: Everything is in the title. I like simplicity of Haskell and would like to use what i write in my c/c++ programs. Thanks a lot by advance. I guess, there are people who have tried, but failed :-) The easiest way would be to make a COM server in Haskell. You should have a look at the HDirect sources, where there are some examples. Generally using a COM dll from Haskell seems to work, while the other way round seems to be problematic. Thank you for your answer. I don't really know what is a COM server but msdn doc probably will say me more on that. I saw a work at microsoft research, called Pan, which used Haskell code, and translated it to C to compile it. But produced code was too obfusquated to reuse it in C sources. So i'm going to try COM solution. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Eval in Haskell
[We now have lost all pretence of topicality] On Sun, Jun 01, 2003 at 08:43:03PM -0700, Ashley Yakeley wrote: Guile seems to be a bit sloppy in general. I think it just keeps a dictionary of symbol bindings and passes it around at runtime. guile (eval '(define b 5)) guile b 5 This particular kind of sloppiness is pretty common in Scheme REPLs: la:~$ kawa #|kawa:1|# (eval '(define b 5)) #|kawa:2|# b 5 #|kawa:3|# la:~$ mzscheme Welcome to MzScheme version 204, Copyright (c) 1995-2003 PLT (eval '(define b 5)) b 5 la:~$ bigloo -- Bigloo (2.5c),--^, `a practical Scheme compiler' _ ___/ /|/ Wed Nov 27 10:49:16 CET 2002 ,;'( )__, ) ' Manuel Serrano;; // L__. email:' \/ ' [EMAIL PROTECTED] ^ ^ -- Welcome to the interpreter 1:= (eval '(define b 5)) b 1:= b 5 1:= la:~$ mit-scheme Scheme Microcode Version 14.9 MIT Scheme running under GNU/Linux Type `^C' (control-C) followed by `H' to obtain information about interrupts. Scheme saved on Tuesday June 18, 2002 at 2:26:05 AM Release 7.7.1 Microcode 14.9 Runtime 15.1 SF 4.40 Liar (Intel i386) 4.115 Edwin 3.112 1 ]= (eval '(define b 5) system-global-environment) ;Value: b 1 ]= b ;Value: 5 1 ]= End of input stream reached Happy Happy Joy Joy. ... though admittedly it's a bit confusing, since define either binds or assigns to a variable, depending on whether it was already bound. Lauri Alanko [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Is my question bad ?
On Saturday 31 May 2003 12:29 pm, Antoine Utonium wrote: I recently asked you who knows how to link haskell-made code to C apps, or call haskell code from C code, or encapsulate, traduce, Haskell code in C code. I just want to use haskell when I need advanced algorithms, C for I/O, and GUI (under windows).. If the library you want to use is already available under COM, I agree with Karl M Syring that Haskell-COM tools (i.e., H/Direct) are the way to go. If they are available as normal C libraries, I'd recommend using either the foreign function interface (ffi) http://www.cse.unsw.edu.au/~chak/haskell/ffi/ or one of the tools that sits atop the foreign function interface. There is a very preliminary and slightly dated overview of all the tools here: http://www.reid-consulting-uk.ltd.uk/docs/ffi.html The best place to ask for information is on the ffi mailing list ([EMAIL PROTECTED]). In general, the more specific your question, the better the answer is likely to be. http://www.haskell.org/pipermail/ffi/ Hope this helps. -- Alastair Reid ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
a readFile problem
Hallo, I have the following problem: my program asks the user for a command, when the command is executed a new command is asked (this is no problem ; an example is in the HUgs distribution namely Main.hs in the Prolog example. However one of the commands is: read filename i.e. read a file and display it. I do not succeed in implementing this. Could anyone give an example of: reading commands in a loop where one of the commands is the read command mentionned above. Or is it not possible in Haskell? I have already wated a lot of time on this, so if anyone gives me an answer I will be very gratefull. Greetings,begin:vcard n:Guido;Naudts, Guido tel;fax:02/538.01.80 tel;home:014/51.32.43 tel;work:02/542.76.01 x-mozilla-html:TRUE url:http://www.just.fgov.be org:Ministerie van Justitie;Algemene Diensten adr:;;Eversstraat 2-8;Brussel;;1000;Belgium version:2.1 email;internet:[EMAIL PROTECTED] title:Informaticus x-mozilla-cpt:;-30680 fn:Naudts, Guido end:vcard