problem specifying location of imported module

Hello everyeone, My main file, ex6.hs, imports Pictures.hs: import Pictures import Data.Char {- .. bunch of code then main...-} main = putStrLn $ show (newHeight imgA imgB) It compiled to an executable and runs just fine: terry@Abulafia:~/haskell/craft-of-fp/ex$ hmake -i../Code ex6 /usr/bin/haskell-compiler -i../Code -o ex6 ../Code/Pictures.o ex6.o terry@Abulafia:~/haskell/craft-of-fp/ex$ ./ex6 32 terry@Abulafia:~/haskell/craft-of-fp/ex$ However, when I attempt to create an executable traceable by Hat, I have some problems: terry@Abulafia:~/haskell/craft-of-fp/ex$ hmake -hat -i../Code ex6 hat-trans -i../Code ../Code/Pictures.hs Creating directories Hat Hat/.. Hat/../Code Wrote Hat/../Code/Pictures.hs /usr/bin/haskell-compiler -i../Code -c -package hat -o ../Code/Hat/Picture\s.o ../Code/Hat/Pictures.hs ghc-6.2.2: error: directory portion of "../Code/Hat/Pictures.o" does not exist \(used with "-o" option.) Above it looks like the wrong directory was created. Hat created the directory Hat/../Code when I think it should have created the directory ../Code/Hat. At any rate, I went ahead and made the directory that the error complained did not exist and then re-ran, but still had errors: terry@Abulafia:~/haskell/craft-of-fp/ex$ hmake -hat -i../Code ex6 hat-trans -i../Code ../Code/Pictures.hs Wrote Hat/../Code/Pictures.hs /usr/bin/haskell-compiler -i../Code -c -package hat -o ../Code/Hat/Picture\s.o ../Code/Hat/Pictures.hs ghc-6.2.2: file `../Code/Hat/Pictures.hs' does not exist terry@Abulafia:~/haskell/craft-of-fp/ex$ Switching to absolute paths for the -i flag did not help and using -d/tmp to force all .o files to be created in one place did not help either. Any input on getting my entire program traceable is appreciated. If you care to look at ex6.hs or Pictures.hs, my entire haskell directory tree can be browsed by the web here: http://www.hcoop.net/~terry/haskell/craft-of-fp ex6.hs is here: http://www.hcoop.net/~terry/haskell/craft-of-fp/ex/ex6.hs and Pictures.hs is here: http://www.hcoop.net/~terry/haskell/craft-of-fp/ex/Code/Pictures.hs ======== As an afterthought, I tried making my project from the directory above both the main file and the imported file, but that failed as well: terry@Abulafia:~/haskell/craft-of-fp$ hmake -iCode ex/ex6 terry@Abulafia:~/haskell/craft-of-fp$ ex/ex6 32 terry@Abulafia:~/haskell/craft-of-fp$ hmake -hat -iCode ex/ex6 hat-trans -iCode Code/Pictures.hs Creating directories Hat Hat/Code Wrote Hat/Code/Pictures.hs /usr/bin/haskell-compiler -iCode -c -package hat -o Code/Hat/Pictures.o Code/Hat/Pictures.hs ghc-6.2.2: file `Code/Hat/Pictures.hs' does not exist terry@Abulafia:~/haskell/craft-of-fp$ Regards, -- Carter's Compass: I know I'm on the right track when, by deleting something, I'm adding functionality.

Above it looks like the wrong directory was created. Hat created the directory Hat/../Code when I think it should have created the directory ../Code/Hat.
I agree. The directory Hat should be put at the end of the import path, not at the begining. This is a problem with hmake, not with the Hat tools themselves. Malcolm, could you modify hmake accordingly?
Any input on getting my entire program traceable is appreciated.
The simple solution would be to have all your modules in one directory. I know it is not nice to copy Pictures.hs, but it is the most simple way. You could also not use hmake but call hat-trans and ghc directly. Basically see what commands hmake executes, modify the paths and reexecute them. A bit more of a hassle. Ciao, Olaf

Olaf Chitil
Above it looks like the wrong directory was created. Hat created the directory Hat/../Code when I think it should have created the directory ../Code/Hat.
I agree. The directory Hat should be put at the end of the import path, not at the begining.
The placement of the Hat directory (at the beginning or end of a path) is dependent on how the directory name is to be interpreted. A path corresponding to the hierarchical module namespace, like Code/Pictures/Jpg.hs should become Hat/Code/Pictures/Jpg.hs whereas a mere relative pathname with a flat namespace should be the opposite, e.g. ../Code/Pictures/Jpg.hs becomes ../Code/Pictures/Hat/Jpg.hs
This is a problem with hmake, not with the Hat tools themselves. Malcolm, could you modify hmake accordingly?
Actually, in this instance hmake guessed the directory correctly. The fault was with hat-trans, which simply assumed all paths were strictly hierarchical. The attached patch should fix it. Regards, Malcolm

You are right that hat-trans and hmake have to agree on the directory structure (although duplicating this information is not nice). Is not the point of the -i option to set the *base* search paths? Such a path should always point to the base of a possibly hierachical namespace. So extending the base with "/Hat" would be correct. This also suggests that hat-trans should always be called with the full hierarchical name of a module. Otherwise hat-trans would need to find out to which hierarchy (given several search paths) the module to be transformed belongs. The guessing method used by hmake and now also by hat-trans based on occurrence of "." or ".." is rather brittle. Ciao, Olaf Malcolm Wallace wrote:
Olaf Chitil
writes: Above it looks like the wrong directory was created. Hat created the directory Hat/../Code when I think it should have created the directory ../Code/Hat.
I agree. The directory Hat should be put at the end of the import path, not at the begining.
The placement of the Hat directory (at the beginning or end of a path) is dependent on how the directory name is to be interpreted. A path corresponding to the hierarchical module namespace, like Code/Pictures/Jpg.hs should become Hat/Code/Pictures/Jpg.hs whereas a mere relative pathname with a flat namespace should be the opposite, e.g. ../Code/Pictures/Jpg.hs becomes ../Code/Pictures/Hat/Jpg.hs
This is a problem with hmake, not with the Hat tools themselves. Malcolm, could you modify hmake accordingly?
Actually, in this instance hmake guessed the directory correctly. The fault was with hat-trans, which simply assumed all paths were strictly hierarchical. The attached patch should fix it.
participants (3)
-
Malcolm Wallace
-
Olaf Chitil
-
Terrence Brannon