Programming R at native speed using Haskell
tweag.io
tweag.io
I have found Haskell very difficult to use with Cabal and its package management. The reason I went to Haskell was to teach myself functional programming. After struggling and going through 2 books I still felt like I hated Haskell due to making the environment just work. I work in three different locations and to get all 5 computers to work in Haskell was a serious pain. This lead me to see what else is out there. It lead me to https://www.coursera.org/course/proglang which introduced me to Racket and I loved it and felt that Racket was the perfect fit for me.
Package management is certainly the worst thing about Haskell at the moment. Just yesterday I had to fight with cabal, and sit through hours of compilation, to build my application with profiling enabled :(
There's recently been a surge of activity in this area though, which seems to have been driven by FPComplete and consulting with industry:
- First there's "Stackage", which is basically a curated version of the package repository Hackage. Anyone can upload a new package to Hackage, and package authors can make breaking changes whenever they like. Stackage takes consistent snapshots of Hackage, where the package versions are known to work together.
- Next there's "Stack", which is an alternative UI for Cabal (ie. it replaces the commandline tools, but uses the same libraries and infrastructure). Nice features of stack are that it can fetch/install GHC (so "bootstrapping" is much easier), and it doesn't use a global package database (cabal has this feature with "sandboxes", but they're opt-in).
- Personally, I use Nix for managing Haskell packages. It's a bit like stack or cabal sandboxes taken to the extreme, although its Windows support is still pretty experimental. It will fetch pre-built packages from a cache, rather than building stuff locally (as long as you're using the defaults, at least).
Take a look at https://www.fpcomplete.com/blog/2015/06/stack-0-1-release for more info.
> This lead me to see what else is out there. It lead me to https://www.coursera.org/course/proglang which introduced me to Racket and I loved it and felt that Racket was the perfect fit for me.
Racket (and Scheme in general) is also an excellent functional programming language. Having dynamic types and macros makes it a very different beast to Haskell, so it's definitely worth learning both :)
Can you speak to how the type systems in Typed Racket and Haskell differ?
I ask because I too have tried scaling Mount Haskell and noped out not long after the base camp. If I continue with Typed Racket, am I getting some or most of what I'd get by learning Haskell? Or is Haskell simply a beast I must slay to become whole?
One cultural issue, rather than a technical one, is that the whole of Haskell is strongly typed, lazy and pure; there's no getting away from it, so every idiom, library and API must take them into account. I imagine Typed Racket's ability to mix and match features will result in more "conservative" code (ie. choosing the type system to match a known approach, rather than inventing a new approach to fit the type system).
1. implement R or something very akin to R as a Racket language. I'd call it "Arket" because is far more Googleable than R or Racket ;-) Functions would be callable either from Arket or Racket.
2. Ensure that all my important R packages work with Arket, either by porting or by virtue of similarity between Arket and R.
3. Use Racket for everything.
I think this would be great until I realize I would need to do a lot of work to create this.
> I'd call it "Arket" because is far more Googleable than R or Racket
From .NET: http://rdotnet.codeplex.com/ there is also a dataprovider directly to F# : http://bluemountaincapital.github.io/FSharpRProvider/
Also there is C++ binding available also: http://www.rcpp.org/
https://tweag.github.io/HaskellR/docs/memory-allocation.html
Both these links have more information on this.
As far as I can tell (and most of this is way over my head) the native R garbage collection is used
I personally don't see this as a way of using R, rather a way of using Haskell.
Yet from what I'm seeing we are only calling R functions from Haskell. I'm probably missing something on the explanation, but how does this speed up R?
Must give it a try then.
If you use them properly, you would not be able to compare p values of experiments directly (a common mistake).