Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

gonadic io posted:

(.|.) for Bools

I read that 3 times over wondering why Haskell had a Boobs operator.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Your best bet is probably to pick a bunch of good articles and save them for offline reading (can be done in most mainstream browsers). I'd start with everything on this page: http://fsharpforfunandprofit.com/site-contents/

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

VikingofRock posted:

Same here. I've never really had any desire to do web stuff, but fart simpson's elm posts make it look so slick.

As long as you stick to Elm's primary use case (UI FRP), then most of your code will look slick. We used elm-svg to make cool data visualizations with animations and all the jazz that people would normally use D3.js for, but without the lovely selector-based programming that the D3 API requires.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I don't think the compiler message is terribly helpful here (I feel like it should be saying the left argument is B, but I could be wrong). However, your fold isn't correct for a tree. You're calling (partial left) and (partial right) which uses the same accumulator (which is a problem) and returns a value of type B. You then try to feed two Bs into a function of type (A -> B -> B).

I think you want your final let..in clause to be something like:

code:
let
  leftFold = fold func acc left
  acc = func value leftFold
in
  fold func acc right
This folds the left sub-tree using acc, generates a new acc from the left-folded sub-tree and the current node's value, then passes that new acc down into the fold for the right sub-tree.

edit: beaten by a mile.

Bognar fucked around with this message at 21:13 on Dec 31, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
My coworker uses Emacs with the Haskell thingy and it seems to work pretty well. I wouldn't call it an IDE per se, but it has syntax highlighting, indentation, and some options for quickly executing your code.

Then again, you'd have to use Emacs.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Walh Hara posted:

I honestly have no idea if these posts about using a Linux VM are sarcastic or not.

Neither do I, but I use a linux VM to write Rust so :shrug:

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Jarl posted:

I get applicative functors now, but it sure took some effort. With that in mind should I prepare myself for a long haul with monoids and monads, or am I already almost there conceptually having understood applicative functors?

Monoids are easy and, despite the name, they have nothing to do with monads in general (some specific monads have a monoid constraint).

Monads aren't significantly harder to understand than Functors or Applicatives, but it might take you a while to grasp the "why" of using them. It took me quite a while at least.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Elm just switched their model from using signals, addresses, and ports to a unifying model of "subscriptions". At first glance it seems pretty promising:

http://elm-lang.org/blog/farewell-to-frp

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Arcsech posted:

The [1..5] syntax was nice, but I'm not too put out by losing it. Backticks I could go either way on, I can definitely see the simplicity of just encouraging |>.

They made a pretty big breaking change, though, to encourage use of |>. (x `andThen` y) translates to (andThen x y), but (x |> andThen y) translates to (andThen y x). They had to flip the argument order of andThen to support this change, which I think is pretty bold.

e: luckily the argument types are incompatible, so it's not possible to compile code that was broken this way.

Bognar fucked around with this message at 20:50 on Nov 15, 2016

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

EmmyOk posted:

Okay that's starting to make a lot of sense to me. Is prefixer just a reference to the original function or a copy? I'm wondering because it seems like prefix' is still available to prefixer which is a string originally from the first-order function.

It's best to think of it as a new function that was built during the calculatePrefixFunction method. Yes, prefix' is still available to the prefix function (this is commonly known as "closing" over a variable, see wikipedia). How it *actually* works is heavily dependent on your language implementation, but the semantics should be the same as if you just created a new function.

It might also help to look at a similar example with numbers:

code:
let buildAdder x =
    let adder y = x + y   // define inner function
    adder                 // return function

let add2 = buildAdder 2  // add2 is a function that takes a parameter and adds 2
let add5 = buildAdder 5  // add5 is a function that takes a parameter and adds 5

printfn "%d" (add2 1)  // 3
printfn "%d" (add5 7)  // 12
Another way to look at the above example is by variable substitution:

code:
let add2 = buildAdder 2

// in the definition of buildAdder, let's replace x with 2
buildAdder 2 =
    let adder y = 2 + y
    adder

// so, we can replace buildAdder 2 above when defining add2:
let add2 y = 2 + y

  • Locked thread