purescript-deprecated/gulp-purescript

Feature request, .psci task

Fresheyeball opened this issue · 10 comments

Grunt purescript has a .psci task. It would be nice if it was here as well.

👍

In the meantime:

var del = require("del");
var gulp = require("gulp");
var exec = require("gulp-exec");

var paths = {
    purs: [
        "app/scripts/**/*.purs",
        "bower_components/purescript-*/src/**/*.purs"
    ]
};

gulp.task("clean-dotpsci", function (cb) {
    del(".psci", cb);
});

gulp.task("build-purs-dotpsci", ["clean-dotpsci"], function () {
    return gulp.src(paths.purs)
        .pipe(exec("echo <%= ':m ' + file.path.replace(process.cwd() + '/', '') %> >>.psci"))
        .pipe(exec.reporter());
});

I just added the dotPsci task. Any feedback is most welcome, thanks for the suggestion.

Fantastic, thanks.

Welcome

Vunderbar!

@ethul

A bit of feedback - or rather, a call for aid - mostly because I'm very new to purescript and I'm a bit unclear on how this feature is intended to be used:

Would you mind providing an example config / a bit of advice? I'm doing this -

gulp.task('purescript', function() {

  // config.puresript.src is an array like so:
  // [  'bower_components/purescript-*/src/**/*.purs*',
  //    'src/**/*.purs'                                                           
  // ]  


  return gulp.src(config.purescript.src)                                        
    .pipe(purescript.psc({                                                      
      noPrelude : false,                                                        
      main      : 'Example',                                                         
      dotPsci   : config.purescript.src
    }))                                                                        
    .pipe(rename('bundle.js'))                                                  
    .pipe(gulp.dest('dist'));

});

... but I'm not clear if I have produced a valid configuration. I do find I have a .psci file generated:

cat .psci
:m bower_components/purescript-math/src/Math.purs

Is this valid content? What should be in here? From psci I find I can load the module I have in bower_components, should I also be able to load a module (Example) from src?

Thank you in advance :)

@craigdallimore

Thanks for checking out gulp-purescript!

Your setup looks pretty good to me. The only issue I see pertains to the dotPsci option being passed to psc.

To generate a .psci file, we have to create a separate gulp task. Usually I write it as follows.

gulp.task('psci', function(){
  return gulp.src(config.purescript.src).
         pipe(purescript.dotPsci());
});

And you're right, the .psci file will contain entries like:

:m bower_components/purescript-transformers/src/Control/Monad/Writer/Trans.purs
:m src/Data/Coyoneda.purs
:m src/Data/Yoneda.purs
:m src/Control/Comonad/Cofree.purs
:m src/Control/Monad/Free.purs

The files after :m should be those in your project and their dependencies, basically the files in config.purescript.src.

If you're interested in a complete gulp-purescript example, the following might be helpful.
https://github.com/ethul/purescript-reactf/blob/master/gulpfile.js

I don't actually have a psc task in that file, but if you have any questions just let me know.

@ethul Thank you for the advice and the example! :)

Welcome!

On Sunday, May 24, 2015, Craig Dallimore notifications@github.com wrote:

@ethul https://github.com/ethul Thank you for the advice and the
example! :)


Reply to this email directly or view it on GitHub
#12 (comment)
.