How do you link to packages during development?

34 views
Skip to first unread message

Sean Hess

unread,
Oct 12, 2016, 12:24:42 PM10/12/16
to haskell-stack
Pretty often while developing an application, I realize that some piece of it would be better as an external library published to Hackage. But I don't really know exactly what the interface will look like. I need a way to iterate the package while I'm developing my application, without needing to republish to hackage every time. 

How do you handle this workflow?

I'd like to put it in its own project folder on my local filesystem, with its own cabal and stack file. Then I want to have my application depend on it. When I make a change to the lib, I want to be able to reload it into my app quickly. 

I attempted to do this by adding the folder to the packages: setting, but it didn't work. See this stack overflow question for more info: http://stackoverflow.com/questions/40003225/stack-how-to-depend-on-a-package-during-development


Dan Burton

unread,
Oct 12, 2016, 12:43:21 PM10/12/16
to Sean Hess, haskell-stack
If only the one application is using it, then don't give it its own stack file, just move it into your project folder. Stack is well designed to handle "megarepos" with multiple packages under a single stack.yaml in this manner.

project/
  stack.yaml
  lib1/
    lib1.cabal
  app1/
    app1.cabal

Stack should also handle things the way you're trying to do it, but I personally have no experience doing it that way; perhaps someone else can advise on that scenario.
--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stack+unsubscribe@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/5db29a15-bc7b-48a4-93dd-86e51de9af48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-- Dan Burton

Bryan Richter

unread,
Oct 12, 2016, 12:44:45 PM10/12/16
to haskell-stack
On Wed, Oct 12, 2016 at 09:24:41AM -0700, Sean Hess wrote:

> Pretty often while developing an application, I realize that some
> piece of it would be better as an external library published to
> Hackage. But I don't really know exactly what the interface will look
> like. I need a way to iterate the package while I'm developing my
> application, without needing to republish to hackage every time.
>
> How do you handle this workflow?

Stack is designed for this workflow. It looks like you've done
everything right (but note that including the stack.yaml in the library
is only strictly necessary for building it independently).

On SO you list the error as

Failed to load interface for ‘Network.Worker’

Does your library list that package under 'exposed-modules' in its Cabal
file?
signature.asc

Sean Clark Hess

unread,
Oct 12, 2016, 12:50:09 PM10/12/16
to haskell-stack
@Dan, That will support my workflow, thank you, I'll give it a shot

@Bryan, Yes, it is listed. I think the "failed to load interface" error only happens because of the build/exit failure error. I don't really know what's going on with the build error. I looked at the log file and it didn't have any useful information in it. 

--
You received this message because you are subscribed to a topic in the Google Groups "haskell-stack" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/haskell-stack/JYt0G0HI5MI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to haskell-stac...@googlegroups.com.

To post to this group, send email to haskel...@googlegroups.com.

Sean Clark Hess

unread,
Oct 12, 2016, 5:33:54 PM10/12/16
to haskell-stack
Starting over made the problem magically disappear. I created a new folder in my project, slowly copied parts into it, and it worked right away. I moved this new folder out into a peer folder and exactly duplicated the structure that was failing before, and it is working. 

It must have been some cached build artifacts or something? I updated the lts resolver halfway through in my main project, maybe that threw it off. 

Thanks for all your help!
Reply all
Reply to author
Forward
0 new messages