
If you're working on a Haskell project that includes packages, and the packages are in subdirectories of the source tree, how do you "build"? In my case, I want to alter the "gloss" package so I unpacked it, changed the name to "customgloss" in the .cabal file, and installed. Meanwhile, I used the package-quallified import GHC feature. So I have to go into that subdirectory and run cabal install, let it recompile everything in there and copy it to the repository, then chdir back out and build/run my main program. How about a "make"-like way that knows if a source file in that package directory has changed, only recompiles the changed parts, and can put the output files in my directory tree with the source rather than copying to the machine repository? How do you normally go about developing a new version of a package? —John

Hi John, On Fri, Apr 25, 2014 at 09:41:32AM -0500, John M. Dlugosz wrote:
How do you normally go about developing a new version of a package?
A cabal sandbox with 'add-source' might help here. If your directory tree looks something like: /whatever/customgloss /whatever/yourproject Then you could do: cd /whatever/yourproject cabal sandbox init cabal sandbox add-source ../customgloss cabal install If your code in 'customgloss' changes, then calling again 'cabal install' in 'yourproject' will rebuild 'customgloss'. But you might rethink if copying 'gloss' that way is really a good long term solution. Greetings, Daniel

On 4/25/2014 10:06 AM, Daniel Trstenjak wrote:
On Fri, Apr 25, 2014 at 09:58:04AM -0500, John M. Dlugosz wrote:
I have no idea what's a good idea; I'm just showing what I've learned thus far. What is the right way to develop a package?
Why have you copied gloss? Have you just added a new function? Have you modified the code?
Because the circles are not round. I've modified one function. Maybe I'll do more with it and invite them to Pull.

On Fri, Apr 25, 2014 at 11:14:41AM -0500, John M. Dlugosz wrote:
Because the circles are not round. I've modified one function. Maybe I'll do more with it and invite them to Pull.
If you're changes are sensible and you could get your changes merged back, than this is certainly the way to go. If you can't get your changes merged back - or for the short term - it might be easier to just copy the specific function, modify and rename it. I don't know nothing about gloss, so would this approach be possible? Copying the whole package seems a bit excessive. Greetings, Daniel

On 4/25/2014 11:26 AM, Daniel Trstenjak wrote:
If you can't get your changes merged back - or for the short term - it might be easier to just copy the specific function, modify and rename it.
I don't know nothing about gloss, so would this approach be possible?
The function is an internal back-end detail, not one the program calls directly. So renaming it would mean changing the caller, etc.

On 4/25/2014 10:06 AM, Daniel Trstenjak wrote:
On Fri, Apr 25, 2014 at 09:58:04AM -0500, John M. Dlugosz wrote:
I have no idea what's a good idea; I'm just showing what I've learned thus far. What is the right way to develop a package?
Why have you copied gloss? Have you just added a new function? Have you modified the code?
To be specific, in Graphics/Gloss/Internals/Render/Circle.hs {-# INLINE circleSteps #-} circleSteps :: Float -> Int circleSteps sDiam | sDiam < 8 = 8 | sDiam < 16 = 16 | sDiam < 32 = 32 | otherwise = round sDiam Originally, the otherwise branch said 64. When drawing my Pappas Chain, the outer circle was not tangent to all the little circles, but clipped through them and when zoomed was obviously a polygon and not a circle at all. So, why's it limited to 64? Maybe we don't want to go crazy if zoomed in deeply, and most of it doesn't show anyway. So I thought I might tinker with it some more to make it proper circle quality only where it intersects the viewport, and crude outside (if not omitted entirely). I might also turn on anti-aliasing, which if not exposed already means adding a function in the private guts to change the setting of the OpenGL handle. But more generally, everyone who develops a package and continues to develop a new version while the old one is installed and used by other components must be doing something (sandbox for this case, I think). And even if a body of code is not intended to be a general purpose library shipped on its own, a big project ought to be divided into parts, so it is desirable to know which files changed and do far less work to build than to compile every single source file again. —John

On Fri, Apr 25, 2014 at 11:26:44AM -0500, John M. Dlugosz wrote:
To be specific, in Graphics/Gloss/Internals/Render/Circle.hs
{-# INLINE circleSteps #-} circleSteps :: Float -> Int circleSteps sDiam | sDiam < 8 = 8 | sDiam < 16 = 16 | sDiam < 32 = 32 | otherwise = round sDiam
Ok, I see, if you have to modify such an internal function, then forking the package might really be the only solution. If you're using a cabal sandbox with 'add-source', then you might not need to rename the gloss package, if cabal first searches for dependencies in the added sources and then on hackage. But I'm not sure about this one. Greetings, Daniel

On Fri, Apr 25, 2014 at 06:59:04PM +0200, Daniel Trstenjak wrote:
On Fri, Apr 25, 2014 at 11:26:44AM -0500, John M. Dlugosz wrote:
To be specific, in Graphics/Gloss/Internals/Render/Circle.hs
{-# INLINE circleSteps #-} circleSteps :: Float -> Int circleSteps sDiam | sDiam < 8 = 8 | sDiam < 16 = 16 | sDiam < 32 = 32 | otherwise = round sDiam
Ok, I see, if you have to modify such an internal function, then forking the package might really be the only solution.
If you're using a cabal sandbox with 'add-source', then you might not need to rename the gloss package, if cabal first searches for dependencies in the added sources and then on hackage.
Yes, that's what it does. Renaming the package should not be necessary. -Brent

OK, use sandbox and "add-source". But does that address the smart "make" concept? That is, will it automatically rebuild the gloss package if a file in it changed, when I compile the program that imports it? On 4/25/2014 12:39 PM, Brent Yorgey wrote:
On Fri, Apr 25, 2014 at 06:59:04PM +0200, Daniel Trstenjak wrote:
On Fri, Apr 25, 2014 at 11:26:44AM -0500, John M. Dlugosz wrote:
To be specific, in Graphics/Gloss/Internals/Render/Circle.hs
{-# INLINE circleSteps #-} circleSteps :: Float -> Int circleSteps sDiam | sDiam < 8 = 8 | sDiam < 16 = 16 | sDiam < 32 = 32 | otherwise = round sDiam
Ok, I see, if you have to modify such an internal function, then forking the package might really be the only solution.
If you're using a cabal sandbox with 'add-source', then you might not need to rename the gloss package, if cabal first searches for dependencies in the added sources and then on hackage.
Yes, that's what it does. Renaming the package should not be necessary.
-Brent

On Sun, Apr 27, 2014 at 10:24:38PM -0500, John M. Dlugosz wrote:
OK, use sandbox and "add-source". But does that address the smart "make" concept? That is, will it automatically rebuild the gloss package if a file in it changed, when I compile the program that imports it?
Yes.

On Fri, Apr 25, 2014 at 4:41 PM, John M. Dlugosz
If you're working on a Haskell project that includes packages, and the packages are in subdirectories of the source tree, how do you "build"?
In my case, I want to alter the "gloss" package so I unpacked it, changed the name to "customgloss" in the .cabal file, and installed. Meanwhile, I used the package-quallified import GHC feature.
While that's not the question you asked, I note that you unpacked gloss which probably means "cabal unpack gloss" (?). This is in general a terrible idea because the latest released version may not be up to the development version and if you want to work sanely, you'll have to put this code in revision control, and you won't use the same as the author and so on... So when you send a patch he may not be able to simply apply it to his latest version and then it'll sit forgotten in his mail box and your work will be lost for the community (ok, I may be overdoing it here...). So the sane alternative is to check on the hackage page if a repository is specified, like here : "git clone https://github.com/benl23x5/gloss" will get you the latest and greatest, already in revision control and facilitate the creation of a pull request in the future (in fact if you have a github account, it's even better to go to this page and fork his repo to have your own version on github). -- Jedaï

"git clone https://github.com/benl23x5/gloss" will get you the latest and greatest
Or, for a recent enough cabal, and properly written cabal files, like the
one from gloss:
cabal get -s gloss
2014-04-29 18:12 GMT+01:00 Chaddaï Fouché
On Fri, Apr 25, 2014 at 4:41 PM, John M. Dlugosz
wrote:
If you're working on a Haskell project that includes packages, and the packages are in subdirectories of the source tree, how do you "build"?
In my case, I want to alter the "gloss" package so I unpacked it, changed the name to "customgloss" in the .cabal file, and installed. Meanwhile, I used the package-quallified import GHC feature.
While that's not the question you asked, I note that you unpacked gloss which probably means "cabal unpack gloss" (?). This is in general a terrible idea because the latest released version may not be up to the development version and if you want to work sanely, you'll have to put this code in revision control, and you won't use the same as the author and so on... So when you send a patch he may not be able to simply apply it to his latest version and then it'll sit forgotten in his mail box and your work will be lost for the community (ok, I may be overdoing it here...).
So the sane alternative is to check on the hackage page if a repository is specified, like here : "git clone https://github.com/benl23x5/gloss" will get you the latest and greatest, already in revision control and facilitate the creation of a pull request in the future (in fact if you have a github account, it's even better to go to this page and fork his repo to have your own version on github).
-- Jedaï
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 4/29/2014 2:03 PM, João Cristóvão wrote:
"git clone https://github.com/benl23x5/gloss" will get you the latest and greatest
Or, for a recent enough cabal, and properly written cabal files, like the one from gloss:
cabal get -s gloss
cool!

On Tue, Apr 29, 2014 at 9:03 PM, João Cristóvão
"git clone https://github.com/benl23x5/gloss" will get you the latest and greatest
Or, for a recent enough cabal, and properly written cabal files, like the one from gloss:
cabal get -s gloss
Very nice, I didn't know this command but cabal has really become a nice tool to put in place and keep up-to-date a development environment covering several packages ! -- Jedaï

On 4/29/2014 12:12 PM, Chaddaï Fouché wrote:
So the sane alternative is to check on the hackage page if a repository is specified, like here : "git clone https://github.com/benl23x5/gloss" will get you the latest and greatest, already in revision control and facilitate the creation of a pull request in the future (in fact if you have a github account, it's even better to go to this page and fork his repo to have your own version on github).
Thanks. I was thinking as much if I make more than a trivial change and want to contribute. I was wondering if the local repository subdirectory needs to be anyplace in particular, or cabal "add source" just takes care of it wherever it's located? —John
participants (5)
-
Brent Yorgey
-
Chaddaï Fouché
-
Daniel Trstenjak
-
John M. Dlugosz
-
João Cristóvão