Re: Binary files with GHC..?
| I have a data structure Library, and two tools. One tool saves a Library, | another one loads it. At the moment, Library must be "shown" by the first | tool (i.e. converted to text format). This must then be re-parsed by the | second tool. | | It would be much simpler, quicker etc. just to save the data structure | directly as binary, and load it directly as binary. There isn't a good way to do this in GHC at the moment. It would be a nice thing to have, but we just havn't got around to it. Any takers? | P.S. The GHC manual seems to take pride in not supporting the Binary class | :-) ("We don't do that" etc) Is it just a portability thing? You've just bumped into Will's sense of humour! Actually I think class Binary disappeared in the 1.2 - 1.3 transition, but that wouldn't stop having a library function to save data structures. Simon
Re: haskell operator precedence
| However, in return, perhaps somebody can supply me with parse trees for | the following: | | - - 1(accepted by nhc and hbc) | (- 1 `n6` 1) where infix 6 `n6` (accepted by nhc, hbc, ghc) | (- 1 `r6` 1) where infixr 6 `r6` (accepted by nhc, hbc, ghc) | | As I read the grammar (for 1.3), all of these should be illegal. In | fact, the compilers don't even give consistent answers for the last | example: ghc and nhc treat it as (-(1 `r6` 1)) while hbc treats it | as ((-1) `r6` 1). Good point! I've fixed this in GHC. It might or might not make it into 2.02 which is in build-and-tar mode at the moment. Simon
Re: -O dear
| Sorry. GHC version 0.29. FiniteMap version 6, it seems ({-# GHC PRAGMA | INTERFACE VERSION 6 #-} at the top). Compilation with verbose output appended | to this message. It's messy ;) In Convert.lhs, add import PreludeStdIO( Maybe ) Simon
Re: -O dear
| grepping for "interface PreludeStdIO" in the 0.29 library interface files | comes up with nothing, so maybe it's not really surprising. (Or is it yet | more "magic"?..) Adding -fhaskell-1.3 does not help, either - the same error | message appears, before it spots all the continuation I/O! I don't understand this. It's in ghc/lib/prelude/PreludeStdIO.hi in the local OGI build of 0.29. I have no idea why it isn't in yours. Maybe Sigbjorn's hack will work. | Why is it that Haskell's "closure rule" does not force a module to export | everything needed for a function to type-check (at least in 1.2)? If something | like "Maybe" is not exported by a module, the user must robotically look at | the module's interface and add the declaration that imports Maybe. Because | it's a robotic action, the computer should do it for you :-) This is all fixed in Haskell 1.3, and therefore in GHC 2.02, which does modules much, much, much better. The closure rule is much relaxed. Simon
Re: specialization
| What I'd really like is a command "specialize module Foo for type Bar", | and moreover, this specialization should happen completely outside | the text of module Foo. (Compare to an instanciation of a generic | package in Ada.) | | Are there any magic ghc options/perl scripts (ouch) that could help? Alas, no. - It's not clear just what "specialize module Foo for type Bar", might mean... which polymorphic types are to be instantiated with Bar? - GHC currently only knows the complete source text of a module when it's compiling that module. Something that might be possible (but we don't do) would be to say ghc Foo.hs -specialise key Int meaning specialise functions with the type variable "key" in their type signature to "Int". I don't think there's much technical problem here, but cross module stuff is always a lot of work. If anyone is inclined to give it a try, do start with 2.02 or later; the cross-module stuff is much better than in earlier versions. Simon
Re: Calling C functions from haskell
At a guess I'd say that libpvm3.a is referring to "xdr_long", "listen" etc, and no library has them. You'll need to find a library that defines them and add a -l flag for it. I think. Simon | But then I tried : | ghc -v -o a.out -L /usr/local/pvm3/lib/SUN4SOL2/ -lpvm3 Main.o | | and it wrote : | | | xdr_long | /usr/local/pvm3/lib/SUN4SOL2//libpvm3.a(lpvmpack.o) | listen | /usr/local/pvm3/lib/SUN4SOL2//libpvm3.a(lpvm.o) | connect | /usr/local/pvm3/lib/SUN4SOL2//libpvm3.a(lpvm.o) | ld: fatal: Symbol referencing errors. No output written to a.out | | Libpvm3.a is PVM library and C programs need only to include pvm3.h and | to be linked with this library. | MatoG.
Re: simple question
| Jin Yang [EMAIL PROTECTED] writes ... | | I wrote a translator in Haskell and it was compiled OK using an earlier ghc | version. Now the ghc at my department (Dept of Computing , Imperial) was | upgrated to ghc0.26 and all my code got a compiling error: |ld: Undefined symbol |___main Jin Yang, I wish I could help but ghc0.26 is now so old that I don't have a copy around to try. You could upgrade to 0.29 (which is solid Haskell 1.2), or to 2.04 (which is Haskell 1.4, but only available in source form just now). Simon
Re: Dinesh Vadhia: Haskell in the Real World ...
Hi! Before raising my questions please point me in the appropriate direction if these questions have been asked before. I have also just requested to join the various Haskell mail lists. My questions are really concerned with the commercial viability of Haskell especially in the face of the Java juggernaut and the development of quality software components. Dinesh, We're working hard on integrating GHC and Hugs with Microsoft's COM (Component Object Model). Perhaps CORBA too in due course, but COM is simpler. That gives us a way to talk to Java (and vice versa). There's a paper you may find interesting "Scripting COM components in Haskell", at http://www.dcs.gla.ac.uk/~simonpj. Erik Meijer and Daan Leijen is doing a lot of work on this too: http://www.cse.ogi.edu/~erik/Personal/Default.html As part of our planned GHC/Hugs integration we'll be doing a lot more work on this component based programming stuff. Do you have a direct interest in this? An application? Simon
Re: Simple usage of GHC
year ago I had the pleasure of using a compiler (for BETA I think) where the basic usage for a novice was Just What You Wanted: % compiler Main.source From there it figured out which other modules it needed, which required recompiling, which object files and libraries where needed for linking etc. I beleive that Objective Caml also has this, although you have to give an option (sigh). Why can't GHC (and all the others for that matter) be that simple? Hugs seems to do the right thing. Good idea. I'll put it on our wish-list. The more people that say "yes please" the more likely it is to get done! Simon
Re: MPC dunce question.
While hacking around with MPCs, trying to define a variant of the Collection class, mutated to suit my own fiendish ends, I ran into this: Intervals.hs:345: Class type variable `e' does not appear in method signature union2 :: s - s - s What's the significance of this restriction? (I presume this is caused by a requirement that all class vars appear in all methods.) I don't recall it being mentioned in the proposal for MPCs, but I may have overlooked and/or forgotten it. I don't suppose it ever really "bites" anyone, since one can always shove the appropriate constraint on the missing variable into the other methods, that do use it, but I don't instantly see why that's The Way to do it. Not a dunce question. I think the only reason for the original restriction in Haskell (with one param) is this: class C a where op :: Int - Int Here op :: C a = Int - Int, and hence *any* use of op is bound to be ambiguous... which instance of C should we choose? Hence the rule. In the multi-paramter case things are less clear: class C a b where op :: a - a Here, op :: C a b = a - a. So suppose we use op on an Int argument. Then we need to find an instance for (C Int b). If there is an instance instance C Int b where ... (and of course no overlapping instances) then we are home. Is that your stituation here? Maybe it is. But more likely you have instance C Int Int where ... and now you're stuck, even if that's the only instance of (C Int t), for any t. Why stuck? Because we ruled out "improvement" which would instantiate b to Int in this case, on the grounds that its the only solution. So, which is your situation? Simon
Re: MPTC
There's no description of the multi-parameter type classes extension in the 3.01 user manual; are the extensions implemented as described in the link below? (I vaguely recollect Simon posting a message on this subject more recently, but I couldn't find it.) http://www.cs.chalmers.se/~rjmh/Haskell/Messages/Display.cgi?id=171 Yes; except that -fallow-overlapping-instances does what it sounds like. It will permit overlapping instances provided one completely overlaps the other; e.g instance C [a] and instance C [Int]. But instanc C (a,Int) and instance C (Int,b) are not legal; becuase then we would not know which instance to use for C (Int,Int). Choice 7a ~ The context in a class declaration (which introduces superclasses) must constrain only type variables. For example, this is legal: class (Foo a b, Baz b b) = Flob a b where... but not class (Foo [a] b, Baz (a,b) b) = Flob a b where ... I tripped across an example from the literature that might motivate relaxing this. It's the monad transformer class from the monadic modular interpreters paper: class (Monad f, Monad (t f)) = MonadT t f where lift :: f a - t f a Thanks for the reminder about this. Examples of where Choice 7a is a really bad thing are still welcome! Simon