Hacker News new | past | comments | ask | show | jobs | submit login

I wanted to use a library to do simple linear algebra, quick and dirty regular expression.

With linear algebra the library HMatrix is broken in more than one place, it also requires me to learn a lot of new types just to do simple matrix decomposition.

Regular expression in haskell requires me to learn a completely new way to do them, I am not under the impression that regular expression is broken in any way in python or javascript that it requires new syntax.

Haskell also does not have access to the browser runtime which is key if you are want maximum exposure for your work - ( no one is interested in binaries anymore ).

There is purescript but its a large layer over javascript and even a simple hello world results in a 2000 LOC compilation of javascript.

I am not a computer programmer, I am an applied Mathematician and haskell requires a lot of work before it can be used for serious work the type of work I do.

Haskell doesnt have the use of use that is offered by things like npm, browserify which are the most awesome tools I have used.




> There is purescript but its a large layer over javascript and even a simple hello world results in a 2000 LOC compilation of javascript.

This really depends on which compilation route you take. `psc-make` will include all of the Prelude and compile to CommonJS modules, which can result in quite a bit of code, but `psc` will trim out all unused functions, and should result in about 10 LOC for Hello World.


> With linear algebra the library HMatrix is broken in more than one place, it also requires me to learn a lot of new types just to do simple matrix decomposition.

What was broken about HMatrix? What library has the best API to you? Algebra[0] from Node?

    var algebra = require('algebra');
    
    var M = algebra.MatrixSpace;
    var R = algebra.Real;
    
    // Create the space of 2x2 real matrices
    var R2x2 = new M(R, 2);
    
    // Create two invertible matrices:
    //
    //       | 1 2 |         | -1 0 |
    //       | 3 4 |   and   |  0 1 |
    //
    var m1 = new R2x2.Matrix([1, 2,
                              3, 4]);
    
    var m2 = new R2x2.Matrix([-1, 0,
                               0, 1]);
    
    // Multiply m1 by m2 at right side
    //       | 1 2 | * | -1 0 | = | -1 2 |
    //       | 3 4 |   |  0 1 |   | -3 4 |
    m1.mul(m2);
    
    console.log(m1.data); // [-1, 2, -3, 4]
    
    // Check out m1 determinant, should be 2 = (-1) * 4 - (-3) * 2
    console.log(m1.determinant.data); // 2
> Regular expression in haskell requires me to learn a completely new way to do them, I am not under the impression that regular expression is broken in any way in python or javascript that it requires new syntax.

What new syntax? I'm not sure what you mean by "learn a completely new way to do them".

Haskell (pcre-light[1]):

    > import Text.Regex.PCRE.Light
    > let numberRgx = compile "[0-9]+" []
    > match numberRgx "the answer is 42" []
    Just ["42"]
Node:

/[0-9]+/g.exec("the answer is 42")[0];

Haskell (regex-tdfa[2]):

> import Text.Regex.TDFA > "the answer is 42" =~ "[0-9]+" :: String "42"

Ahh, I think I see what you mean now. You want the familiar /regex/string syntax right? There used to be a QuasiQuoter (template haskell library) that allowed syntax like:

    ghci> [$rx|[0-9]+|] "the answer is 42"
    Just ["42"]
However it[3] seems to have bitrotted and everyone else is using the "needle" =~ "match" syntax.

EDIT: Found a useful website comparing language implementations, namely regex in perl vs Haskell:

http://langref.org/haskell+perl/pattern-matching

0: http://g14n.info/algebra/examples/quick-start

1: http://hackage.haskell.org/package/pcre-light

2: http://hackage.haskell.org/package/regex-tdfa

3: http://hackage.haskell.org/package/regexqq (bitrotted)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: