Live data from Hacker News

Elm in Production: 25K Lines Later

charukiewi.cz

71–80 of 278 posts

Re: Elm in Production: 25K Lines Later

#71
post #8

First: > Elm has an incredibly powerful type system Near the end of the article: >Want to decode some JSON? Hard, especially if the JSON is heavily nested and it must be decoded to custom types defined in your application. IMHO the lack of typeclasses/traits is really hurting Elm. Take haskell f.e. {-# LANGUAGE DeriveGeneric #-} import GHC.Generics data Person = Person { name :: Text , age :: Int } deriving (Generic,…

In Rust you can also just make your struct deserializable, use a JSON lib to deserialize a string and get the corresponding object in a Result type.

The amount of work you need to do in Elm instead is huge.

Re: Elm in Production: 25K Lines Later

#72

Earlier quoted context omitted.

What makes you say Haskell is an abomination?

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

You certainly would need a PhD to fully understand Monads from that small JavaScript snippet. The Haskell link you gave gives Phil Wadler's original paper as the first link. It is easy to read, explains everything beautifully and full of many examples. Learn some basic Haskell for no other reason than to read seminal papers such as these. To favour some random JavaScript hacker on the internet and steer others away from the original work is anti-intellectualism.

Re: Elm in Production: 25K Lines Later

#73

Earlier quoted context omitted.

What makes you say Haskell is an abomination?

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

> Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of JavaScript

So presumably the same concepts can be explained in 5 to 10 lines of Haskell too.

I think you're confusing the refinement and polishing of ideas that's taken place in Haskell over the last two decades with the succinct presentation of those ideas once they've been worked out.

Re: Elm in Production: 25K Lines Later

#74
post #54

Earlier quoted context omitted.

It seems like there's no solutions for generic JSON encoding for OCaml/BuckleScript/Reason either though. I've worked on various ways to do JSON encoding in Purescript through datatype generics, but the recent RowToList machinery lets us use record types directly. I have a post and some links collected if anyone is interested: https://www.reddit.com/r/purescript/comments/6mss5o/new_in_p... http://qiita.com/kimagure/i…

Yojson [0] provides a generic way to read JSON in OCaml. Mostly by pre-defining a type that contains any valid json value. [0] https://github.com/mjambon/yojson

Right, there are some various approaches but I've had a few OCaml users tell me there were some reasons why they weren't/couldn't be used on the front end, sadly. Would really like to see some demos otherwise though

Re: Elm in Production: 25K Lines Later

#75

Earlier quoted context omitted.

What makes you say Haskell is an abomination?

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

> You need a PhD in type theory to get anywhere.

That is extremely false. Haskell isn't even a good playground for academic type theory -- you'd want Agda etc. for that. The development of the language over the last few years has been characterized by pragmatism and a focus on backwards-compatibility, which is why you can take code from something like ten years ago and have it run without issues on modern versions of the Haskell compiler with little to no modifications. (Let's not talk about how long code written in "modern" JS lasts.)

And I'd really like to see type class constraint resolution with functional dependencies, or Hindley-Milner type checking, or something of that sort implemented in "5-10 lines" of JS.

"There he goes again with his mumbo-jumbo," you say. That's right, you don't need to care about those things to write Haskell. What you meant is implementations of typeclasses ("interfaces") like Monad, Functor, and so on: they don't take much more code in Haskell.

  Array.prototype.chain = function (f) {
    return this.reduce((acc, it) => acc.concat(f(it)), [])
  }

  instance Monad [] where
    xs >>= f = concat (map f xs)
    return = pure
And we didn't even have to go the "this" route! Notice that your 5 - 10 lines of JS don't let you write code that works in any monad, whereas I can easily write

  whenM :: Monad m => m Bool -> m () -> m ()
  whenM cond action = do
    condition 
In Elm, you'd have List.whenM, Array.whenM, Maybe.whenM, ... or a straight-up false type signature like their Eq ones, and in JS, a bunch of prototype methods with no unifying threads.

--

As for an example of why I think Haskell has the right ideas (few of us will say it's the "best language evar"):

I'd really like to see a JS version of the Servant library, which takes an API spec for a server and actually generates a fully functional server from that. Here's a description:

https://news.ycombinator.com/item?id=14149200

Does this strike you as idle theoretical self-enjoyment?

Re: Elm in Production: 25K Lines Later

#76
post #69

Earlier quoted context omitted.

The solution isn't more "pragmatism", it's an actual "incredibly powerful type system" like Haskell's. In my projects JSON decoding is just instance FromJSON Foo and that's it.

Nope. The solution is actually "more pragmatism", not "here's a thing that requires a PhD in type theory to understand".

At this point you just sound like a troll.

Re: Elm in Production: 25K Lines Later

#77
post #61

Earlier quoted context omitted.

I don't think many people (and not the parent) "equate" FP with Haskell, but Haskell is in a way the most functional mainstream language because it is the only lazy one. You can have a purely functional language without laziness in principle, but, as Simon Peyton-Jones points has said, laziness, despite having serious costs, keeps a language designer honest by making it impossible to add side effects. The non-lazy la…

> Haskell is in a way the most functional mainstream language 1. Is it the most functional language because it's lazy? No 2. Is it the most mainstream language because it's lazy? No 3. Is it the most functional mainstream language because it's lazy? No + no = no Laziness does not a functional language make. > You can have a purely functional language What would be the purpose of a pure FP? Oh. There would be no purpo…

>Laziness is delayed execution. That's it. There's _nothing_ stopping you from delaying a side effect.

This is true, but unconstraimed side effects are too difficult to reason about in a lazy language to make them practical. So in practice, very few lazy languages have unconstrained side effects.

Re: Elm in Production: 25K Lines Later

#78
post #72

Earlier quoted context omitted.

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

You certainly would need a PhD to fully understand Monads from that small JavaScript snippet. The Haskell link you gave gives Phil Wadler's original paper as the first link. It is easy to read, explains everything beautifully and full of many examples. Learn some basic Haskell for no other reason than to read seminal papers such as these. To favour some random JavaScript hacker on the internet and steer others away f…

Ah, here comes the condescending tone I've so come to appreciate from the Haskell programmers.

"Go and read", "anti-intellectualism".

Re: Elm in Production: 25K Lines Later

#79
post #73

Earlier quoted context omitted.

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

> Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of JavaScript So presumably the same concepts can be explained in 5 to 10 lines of Haskell too. I think you're confusing the refinement and polishing of ideas that's taken place in Haskell over the last two decades with the succinct pres…

But they can't, can they. Or we wouldn't have the bazillion monad tutorials.

The funny thing, this is the trouble that plagues other Haskell-inspired work (such as Purescript)

Re: Elm in Production: 25K Lines Later

#80
post #75

Earlier quoted context omitted.

Short version: You need a PhD in type theory to get anywhere. Basically every obscure overly complicated concept that Haskell throws at you (all the while pretending to be the only true FP language out there) can be explained in 5 to 10 lines of Javascript: https://github.com/hemanth/functional-programming-jargon Compare and contrast. - Monad explained in Javascript: https://github.com/hemanth/functional-programming-…

> You need a PhD in type theory to get anywhere. That is extremely false. Haskell isn't even a good playground for academic type theory -- you'd want Agda etc. for that. The development of the language over the last few years has been characterized by pragmatism and a focus on backwards-compatibility, which is why you can take code from something like ten years ago and have it run without issues on modern versions of…

> This is extremely false [referring to "You need a PhD in type theory to get anywhere."]

almost immediately followed by

> And I'd really like to see type class constraint resolution, or Hindley-Milner type checking

You don't even see the irony in that, do you?

> they don't take much more code in Haskell:

riiight. I won't even go into the number of things that need to be explained there before you even start explaining what the code does.

Post reply on HN