Functional-Javascripts icon indicating copy to clipboard operation
Functional-Javascripts copied to clipboard

more_functional

Open major-lab opened this issue 12 years ago • 7 comments

Hello @DrBoolean, thanks for your great collection of functional techniques for JS! I already used several functions from it, but today I tried to load the whole thing and got

Error: Cannot find module './more_functional'

Am I missing some file, do I have to rename something, or is this dependency not necessary?

major-lab avatar Mar 12 '13 20:03 major-lab

Hi major-lab.

That's great to hear you're playing with it!

That's an artifact. I apologize, this sways from being ready to use and totally in dev.

more_function is what we called the Prelude library beforehand. So if you remove that dependency and require prelude.js instead, all should be well.

Hope that helps!

DrBoolean avatar Mar 12 '13 20:03 DrBoolean

Hi, thanks for your help, that worked indeed, but I got a new error. I try to do pattern matching, and am missing the function groups_of apparently:

        throw e; // process.nextTick error, or 'error' event on first tick
              ^
ReferenceError: groups_of is not defined

Do you have this somewhere?

major-lab avatar Mar 12 '13 20:03 major-lab

Haha man, we gotta clean this up groups_of should be groupsOf

DrBoolean avatar Mar 12 '13 20:03 DrBoolean

Ok, here we go :smiley: Now i am missing $:

        throw e; // process.nextTick error, or 'error' event on first tick
              ^
ReferenceError: $ is not defined

major-lab avatar Mar 12 '13 20:03 major-lab

Is that for pattern matching?

I haven't used that in a bit...

I think we're mainly supporting these now:

https://github.com/loop-recur/FunctionalJS https://github.com/loop-recur/PreludeJS https://github.com/loop-recur/typeclasses

Which should get ya most of the haskell goodness. I think the pattern matching library ended up being less useful than we though so we dropped it.

DrBoolean avatar Mar 12 '13 20:03 DrBoolean

Oh, how unfortunate.. i was just trying out pattern matching. Anyways, thanks for the library, it is great so far!

major-lab avatar Mar 12 '13 20:03 major-lab

No prob.

To answer your previous question, btw I think you can do something lik this:

var $ = Match.parameter; var _ = Match.wildcard;

Color = Data(function(){ return ({ Red: {}, Green: {}, Blue: {}, Yellow: {} })}); Point = Data(function(){ return ({ Pt: { x: Number, y: Number, color: Color } })});

var points = Match (

Red, function() { return "Was Red"; },

Pt(1,$, _), function(n) { return "Was"+n; },

Green, function() { return "Was green"; },

$, function() { return "nah"; } );

DrBoolean avatar Mar 12 '13 20:03 DrBoolean