Default name of target executable

Hello! When I work on a program which is going to be named LongProgramName, I usually put the Main module in file LongProgramName.hs. It would be nice if I could build it with --make like this: $ ghc --make LongProgramName instead of $ ghc --make LongProgramName -o LongProgramName Does anyone rely on the first one producing a.out? Because of this long syntax and comand-line completion I've even once lost the source code. I forgot to remove the .hs at the end of line: $ ghc --make Prog -o Prog.hs Best regards Tomasz

Tomasz Zielonka
Because of this long syntax and comand-line completion I've even once lost the source code. I forgot to remove the .hs at the end of line: $ ghc --make Prog -o Prog.hs
If you want, I can tell you about this great version control system I'm using :-) -k -- If I haven't seen further, it is by standing in the footprints of giants

On 10/10/05, Ketil Malde
Tomasz Zielonka
writes: Because of this long syntax and comand-line completion I've even once lost the source code. I forgot to remove the .hs at the end of line: $ ghc --make Prog -o Prog.hs
If you want, I can tell you about this great version control system I'm using :-)
It was before I acquired the habit to put even the smallest programs in darcs. And even if I did use darcs - I usually at least try to compile the new code before recording it. Anyway, this is not the biggest reason for my request. What bothers me more is typing the redundant command over and over again. Best regards Tomasz

Am Montag, 10. Oktober 2005 08:38 schrieb Tomasz Zielonka:
On 10/10/05, Ketil Malde
wrote: Tomasz Zielonka
writes: Because of this long syntax and comand-line completion I've even once lost the source code. I forgot to remove the .hs at the end of line: $ ghc --make Prog -o Prog.hs
If you want, I can tell you about this great version control system I'm using :-)
It was before I acquired the habit to put even the smallest programs in darcs. And even if I did use darcs - I usually at least try to compile the new code before recording it.
Anyway, this is not the biggest reason for my request. What bothers me more is typing the redundant command over and over again.
Why don't you use a small shell script for this?
Best regards Tomasz
Best wishes, Wolfgang

Why don't you use a small shell script for this?
These kinds of answers are all too abundant, no offense meant. :-) There are lots of things that *can* be done already, that doesn't mean that we can't improve them! Using a shell script is a possible work-around, but certainly not *the* solution. If there is no real reason for ghc to spit out a.out files, then surely choosing the exe name from the main input file would simplify a programmer's life. And for applications that desperately want a.out, well, there's still the -o flag, right? I second Tomasz suggestion. /Niklas

Am Montag, 10. Oktober 2005 11:55 schrieb Niklas Broberg:
[...]
Using a shell script is a possible work-around, but certainly not *the* solution. If there is no real reason for ghc to spit out a.out files, then surely choosing the exe name from the main input file would simplify a programmer's life. And for applications that desperately want a.out, well, there's still the -o flag, right?
Maybe the makers of GHC wanted GHC to be "GCC compatible".
[...]
Best wishes, Wolfgang

On 10/10/05, Wolfgang Jeltsch
Am Montag, 10. Oktober 2005 11:55 schrieb Niklas Broberg:
[...]
Using a shell script is a possible work-around, but certainly not *the* solution. If there is no real reason for ghc to spit out a.out files, then surely choosing the exe name from the main input file would simplify a programmer's life. And for applications that desperately want a.out, well, there's still the -o flag, right?
Maybe the makers of GHC wanted GHC to be "GCC compatible".
With --make it could be more "make compatible", ie $ ghc --make Prog woud be similar to $ make Prog Also, ghc --make Prog is not "GCC compatible". Try running 'gcc Prog' when the source is in Prog.c Perhaps the new behaviour should be enabled when using Prog without the .hs suffix. Best regards Tomasz

Hi, While working on a toy compiler I realized that Data.Set.Set (Set) is not an instance of the Functor class. In other words: 'fmap' is not defined on it. I tried various ways of defining an instance but I failed. The reason is quite interesting: Set is a type constructor (* -> *) so it should qualify it for being a Functor. (In a sense it is very similar to a Map or a list.) However, most Set functions require the elements of the Set to be an instance of Ord. The problem is that this constraint cannot be deduced from the instance declaration for Functor: instance Functor Data.Set.Set where fmap f s = Data.Set.map f s GHCi: Could not deduce (Ord a, Ord b) from the context (Functor Data.Set.Set) arising from use of `Data.Set.map' at ... Probable fix: add (Ord a, Ord b) to the class or instance method `fmap' In the definition of `fmap': fmap f s = Data.Set.map f s In the definition for method `fmap' In the instance declaration for `Functor Data.Set.Set' On the other hand, it seems intuitively natural to make Set an instance of fmap. Any ideas on how to do it? Thanks and Regards, Lajos Nagy

On Tuesday 11 October 2005 18:16, Lajos Nagy wrote:
While working on a toy compiler I realized that Data.Set.Set (Set) is not an instance of the Functor class. In other words: 'fmap' is not defined on it. I tried various ways of defining an instance but I failed. The reason is quite interesting: Set is a type constructor (* -> *) so it should qualify it for being a Functor. (In a sense it is very similar to a Map or a list.) However, most Set functions require the elements of the Set to be an instance of Ord. The problem is that this constraint cannot be deduced from the instance declaration for Functor:
[...]
On the other hand, it seems intuitively natural to make Set an instance of fmap. Any ideas on how to do it?
Hi, you are not the first one to observe this. AFAIK, there is no really satisfactory solution available. The general problem is discussed and a solution (a language extension) proposed in (http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps). Cheers, Ben

Lajos Nagy
On the other hand, it seems intuitively natural to make Set an instance of fmap.
Indeed. While I generally like the overloaded, qualified names, I find it annoying when, like 'map', they clash with Prelude imports. Which means that, in a module using Data.Set, I must either use it all qualified, or import it twice (qualified and hiding map), or explicitly import Prelude hiding map. (Better solutions wanted!) -k -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde wrote:
Indeed. While I generally like the overloaded, qualified names, I find it annoying when, like 'map', they clash with Prelude imports. Which means that, in a module using Data.Set, I must either use it all qualified, or import it twice (qualified and hiding map), or explicitly import Prelude hiding map. (Better solutions wanted!)
I think, you should import qualified Data.Set as Set only and use "Set.map" rather than the deprecated "mapSet" (most other names from Data.Set make more sense with the "Set." prefix) Christian

Christian Maeder
I think, you should
import qualified Data.Set as Set
only and use "Set.map" rather than the deprecated "mapSet"
(most other names from Data.Set make more sense with the "Set." prefix)
I can do this of course, but I think it would be nice to be able to use it unqualified in modules that only uses Sets (and doesn't use e.g. Maps or List.(null|map)). If I always have to qualify it, what is the advantage of Set.map instead of mapSet? (Oh, right, I can "import qualified List as Set" -- but then I still have to change "member" to "elem" etc etc.) -k -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde wrote:
the advantage of Set.map instead of mapSet?
Well, you know that the unqualified name is "map", i.e. also for Data.Map it's not mapMap or mapFM but <YourChoice>.map.
(Oh, right, I can "import qualified List as Set" -- but then I still have to change "member" to "elem" etc etc.)
I think, that was discussed when including Data.Set and Data.Map (but only isEmpty became null). Replacing the import of Set by List does not work well, but Data.Set could be easily replaced by a different Set implementation with the same (or a similar enough) interface. Christian

On Mon, Oct 10, 2005 at 11:40:21AM +0200,
Wolfgang Jeltsch
Why don't you use a small shell script for this?
Or better, a rule in the Makefile, with suffixes: %: %.hs ghc --make -o $@ $^ So, you just have to type "make LongProgramName".

On 10/10/05, Stephane Bortzmeyer
On Mon, Oct 10, 2005 at 11:40:21AM +0200, Wolfgang Jeltsch
wrote a message of 28 lines which said: Why don't you use a small shell script for this?
Or better, a rule in the Makefile, with suffixes:
%: %.hs ghc --make -o $@ $^
How about module dependencies? You would have to handle them in the Makefile (ghc -M?). I'm not saying it's difficult, but it's enough hassle that in case of small "scripts" I would still prefer to use ghc --make directly. Best regards Tomasz

Tomasz Zielonka wrote:
When I work on a program which is going to be named LongProgramName, I usually put the Main module in file LongProgramName.hs. It would be nice if I could build it with --make like this:
$ ghc --make LongProgramName
instead of
$ ghc --make LongProgramName -o LongProgramName
My convention is to use a file name starting with a lower case letter (to avoid confusion with normal modules) and "hmake" is able to make the corresponding binary (using ghc).
Does anyone rely on the first one producing a.out?
I don't or maybe only to "find" binaries that should be deleted.
Because of this long syntax and comand-line completion I've even once lost the source code. I forgot to remove the .hs at the end of line:
I'ld appreciate if ghc would make a binary corresponding to the top-level file name (irregardless of the danger of overwriting files) Christian
participants (8)
-
Benjamin Franksen
-
Christian Maeder
-
Ketil Malde
-
Lajos Nagy
-
Niklas Broberg
-
Stephane Bortzmeyer
-
Tomasz Zielonka
-
Wolfgang Jeltsch