create and install my own local packages

42 views
Skip to first unread message

Michael Mossey

unread,
Apr 18, 2018, 3:23:53 PM4/18/18
to purescript
I'm interested in creating my own Purescript packages for personal use. However, I'm not very familiar with bower or pulp.

My goal is to have packages that I use across several personal projects. If I were using Haskell (ghc) I would just put the source code somewhere on the include path and use the same include path for every project. However, with Purescript and bower, my impression is that I need to have a local installation for each project.

Let's say I'm developing this "package" code in a project I created with bower. Now it's time to turn it into a package and install it in other projects. How do I do that?

Mike

Alex Berg

unread,
Apr 19, 2018, 8:11:01 PM4/19/18
to purescript
What are you used to?

The PureScript compiler will simply compile the source paths you give to it. If a source file is in a different directory, the compiler won't care.

So, if you are working on `~/Code/Project1` and you want to include some files from `~/Code/Project2`, you can include it Project2 when compiling Project1 by doing something like this:

`$ purs compile 'src/**/*.purs' '~/Code/Project2/src/**/*.purs' `

If you want a more convenient way of doing this, I think you'll need to invent it yourself, because I don't know of a better way.

An alternative way (but maybe not better) is to push your shared projects up to GttHub, then include that repo as a dependency of `~/Code/Project1` using a dependency manager. If you use bower, then just add it to your bower.json file, like "mossey/Project2". If you use psc-package, then you just add that repo to a custom package-set you maintain, perhaps also on GitHub. You could also DIY using a Makefile, or just `git clone https://github.com/mossey/Project2 ~/Code/Project1/github-deps` and include in your build with `purs compile "src/**/*.purs" "github-deps/*/src/**/*.purs"`

Does this help you?

Michael Mossey

unread,
Apr 20, 2018, 3:35:15 PM4/20/18
to purescript
I guess that I'm under the impression that installing packages with bower and building with pulp rather than purs gives me some added value. Is that the case?

I want to make sure everything words with psc-ide-mode on Emacs. Perhaps that requires a bower.json and all that? I'm not sure.

Mike

Alex Berg

unread,
Apr 20, 2018, 5:07:24 PM4/20/18
to purescript


I don't use emacs, and I don't use pulp very often, but they both support specifying extra PS source directories.

https://github.com/epost/psc-ide-emacs#go-to-definition-m-
((purescript-mode
  . ((psc-ide-source-globs
      . ("src/**/*.purs" "bower_components/purescript-*/src/**/*.purs")))))

https://github.com/purescript-contrib/pulp#pass-through-options

Maybe like this?

pulp build -- "/some/other/dir/*/src/**/*.purs"

Harry Garrood

unread,
Apr 20, 2018, 5:25:48 PM4/20/18
to pures...@googlegroups.com
If you're using Pulp, and you want to specify an extra directory with source files to include, you're better off using the --include flag, like, say, `pulp build --include extra-sources` if there is a directory called "extra-sources" inside the current directory.

Harry
> --
> You received this message because you are subscribed to the Google
> Groups "purescript" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to purescript+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/purescript.
> For more options, visit https://groups.google.com/d/optout.

Michael Mossey

unread,
Apr 22, 2018, 1:08:55 AM4/22/18
to purescript
I think something is getting lost here... let me back up. My need to create a set of modules that will be used in a few different projects. 

Why am I using pulp and bower? Mostly because I'm learning Purescript through the "Purescript by Example" book, which uses it.

I know how to create a project and install packages with bower.

So I was thinking, this might be a good way to include common code... make it into a package and install with bower. 

Of course, maybe none of this is a good way to do things for my use case. I'm only trying to follow the book.

Maybe I should just have some extra source directories included with every pulp build.

Mike
Reply all
Reply to author
Forward
0 new messages