Live data from Hacker News

Why GitHub used Haskell for Semantic

github.com

181–190 of 214 posts

Re: Why GitHub used Haskell for Semantic

#181
post #178

Earlier quoted context omitted.

But I've done a bit of Clojure, and I've done a bit of Immutable.js, and particularly when you have a deeply-structured piece of data, "mutating" something a few levels down gets really ugly. As opposed to what languages?

(assoc foo "bar" (assoc (get foo "bar") "alice" (assoc (get (get foo "bar") "alice") "bob" 12))) vs foo.bar.alice.bob = 12;

  (assoc-in foo ["bar" "alice" "bob"] 12)
Of course, in clojure you mostly use :keywords instead "strings" as keys which has a ton of benefits.

There's also specter if want something more powerful at the cost of an additional lib.

https://github.com/nathanmarz/specter https://www.youtube.com/watch?v=rh5J4vacG98

Re: Why GitHub used Haskell for Semantic

#182

Earlier quoted context omitted.

In fighting games, characters are sometimes described in terms of their “skill cap” and “skill floor”. The “skill cap” is how well you can play, if you really invest in this character. The “skill floor” is about how bad things can get if you don’t play that well. Some characters are very approachable and easy to play. If you don’t know what you are doing, it’s alright — you can muddle through. If you play them in a r…

I have never read a CS paper. I do not know Category Theory. I failed high school maths. I run three business on Haskell.

In Super Smash Brothers, there are some people who play and win with Zelda. Just not that many.

Re: Why GitHub used Haskell for Semantic

#183

Earlier quoted context omitted.

I have never read a CS paper. I do not know Category Theory. I failed high school maths. I run three business on Haskell.

In Super Smash Brothers, there are some people who play and win with Zelda. Just not that many.

I don’t say “I failed high school maths” because I’m proud of it. I’m not special. I’m not particularly clever. I don’t know how else to drive the point home that you don’t need to be a genius to build software and enjoy doing it in Haskell.

Re: Why GitHub used Haskell for Semantic

#184
post #138
post #90

The control flow section perplexed me a bit, just because you can embed a DSL in Haskell with monads doesn’t mean that “control flow isn’t embedded in the language”. You still have a main entry point and all functions are executed top to bottom albeit with lazy semantics. You could write a DSL and interpret it with C# with all of the properties they want. Haskell is better for this sort of task but their reasons seem…

> all functions are executed top to bottom albeit with lazy semantics. No? There is no "top to bottom" execution, that's the whole point of the lazy semantics.

My point was that you still call functions and return from them, you have conditionals, and you still have a call stack with lexical scoping (and Main). You have a very similar control flow model compared to any other language. The other comment explained pretty well what they meant by having the control flow not being dictated by the language - with the expressiveness of haskell’s core language you can dictate your control flow for your embedded dsl.

Re: Why GitHub used Haskell for Semantic

#185
post #18

Earlier quoted context omitted.

"Now, maybe something about Haskell Enlightenment obviates this case entirely in a way I'm not seeing." Many times the answer is that with a different structure you don't need deep mutation to be a critical part of your program. After all, "deep mutation" isn't considered a great idea in object-oriented languages either, where it constitutes a violation of the Law of Demeter [1], either in letter or in spirit (i.e.,…

Let me add that lenses are not just a Haskell thing. It's a simple (and beautiful IMHO) concept from functional programming that can be introduced in many languages. Also, you can have lenses without the cryptic operators.

The cryptic operators are by far the worst thing about learning the basics of Haskell.

The language is already hard to learn because of all the wonderful and mindblowing concepts but the syntax is super frustrating and takes the difficulty to another level.

Re: Why GitHub used Haskell for Semantic

#186
post #89

Earlier quoted context omitted.

> I don't mean to be dismissive, but when your plans are to open source something corporate sponsored, you should do it in a way that benefits the community significantly This is a super weird objection to me; is your argument that open sourcing something that might not be useful to others is worse than just keeping it closed-source? Even if literally nobody else ever gets any use from this, I don't see why it's harm…

More if you're going to open source something that widely useful you should write it in a common language. Otherwise the public benefit to open sourcing it is less. In this case, the project is almost as useful as binaries. It's unlikely that many will able to integrate into existing systems or even have the Haskell skills to work with it

I guess I just have a fundamentally different view on open source than you. I don't see anything wrong with a company writing a tool in the way that is best for them given their current circumstances (e.g. skills of the team working on it) and then open sourcing it. The team that wrote this obviously felt that Haskell was their best choice for this project, and I don't begrudge them for open sourcing it just because it might not be useful for others.

Re: Why GitHub used Haskell for Semantic

#187

Earlier quoted context omitted.

I don't know. I've been slinging Haskell on the side for the better part of a decade and do most of my day to day in RoR (trying to start moving clients over to Elixir/Phoenix.) Haskell is an amazing language. I would totally buy that Haskell teams probably win in the medium to long-term as the wins you get in terms of support/maintenance/extensibility are pretty obvious. However, anecdotally, Haskell forces me (and…

Yesod is plenty mature. There are reasonable docs and examples. I'm not sure what else to tell you. I run three web businesses on Yesod, and it accounts for 100% of my income. I'm also not a great programmer, and have a long history of just "hacking things out". The stuff works, and it's ready to go, today .

I spent 7 months trying to build a json api using yesod with a friend. We had nothing but headaches. Its insanely hard to find example code or search issues when using yesod. Hardly anything exists about it on stack overflow already so any time I had an issue I had to post it on SO and wait a day for someone to answer it which meant I could only do about an hour of programming a day. I ended up giving up used RoR and replicated more than the 7 months worth of work in a few weeks.

There is a very good reason RoR is far more popular than haskell web apps. Its just so easy to get started with rails, there is a near infinite amount of information online.

Re: Why GitHub used Haskell for Semantic

#188

Earlier quoted context omitted.

Honestly this is true. Most of the world doesn't give a shit if a page on their web store is broken. They get an exception email and then fix it, no real loss. While switching over to haskell may make your software more stable, at the end of the day the amount of extra time spent writing it in a more stable language is going to cost the business a lot more than a slightly buggy website will.

Completely false. Many “real world” businesses are shipping web apps in Haskell. Anecdotally, they take less time to write than the equivalent Rails app.

Many web apps might be written in haskell but I assure you many many many more are written in ruby. I very much doubt you will find a haskell developer willing to build your web store in haskell for $15/hour. With rails you can just import Spree, make a few modifications and host it and you are done.

Re: Why GitHub used Haskell for Semantic

#189
post #136

This week I need to do some crazy validation in C#. I wrote a bunch of plain imperative code. Then I thought I could use applicative validation with LinQ. I tried to wrote Maybe, Either and Validation, and wanted to extract an applicative and monadic interface. Then I found there are huge pitfalls and difficulties to do it properly. I also tried the same thing in JavaScript, while it's not a safe language, but the eq…

It sounds like you're trying to judge Haskell based on your experience of Java and C#? Don't do that. The Java/C# type systems have substantial limitations, but that's not a problem of type systems in general, it's a problem of C++-family languages specifically.

On the contrary, I'm not judging Haskell and Haskell is one of the most Perlis languages to me.

I'm judging Java and C# etc (statically typed but not flexible) are Anti-Perlis because it draws too many imagination boundaries to their users.

Re: Why GitHub used Haskell for Semantic

#190
post #97

Earlier quoted context omitted.

If you want to be productive in Haskell, the Monad typeclass is an important tool to familiarize yourself with. That said, unless you are working on the internals of a few libraries, you don't really ever need to know serious category theory in order to be very productive. If you don't already have a background in abstract algebra or category theory, I think a better approach to learning these abstractions is slowly…

Thanks for this info. What I really want to know is the value prop for learning/using monads etc. The examples of IO, State, Maybe, List, STM given seem like they'd be dealt with just fine in Clean.

I think it's important to be precise about how the monad abstraction and type system features interact in order to combine pure and impure code. I wrote a comment elsewhere in the thread (https://news.ycombinator.com/item?id=20112333) where I conclude that while the monad abstraction is useful for making a usable interface and writing programs which are agnostic to how their state is implemented, the fundamental work of distinguishing pure and impure computations is accomplished with a combination of type system features and compiler magic.

The case is exactly the same for the Clean language as for Haskell and indeed Clean has Monad instances for all of the types I mentioned aside from STM, so there are no concerns with dealing with those monadic abstractions in Clean. (https://imgur.com/a/sjsDiZq, https://cloogle.org/#using%20Monad) Since IO is Haskell's type that marks impure computations, we can compare Haskell's implementation to the equivalent one in Clean (interface: https://cloogle.org/src/#Platform/System/IO;line=10, implementation: https://cloogle.org/src/#Platform/System/IO;icl)

In Clean, IO is implemented as follows:

    :: IO a = IO .(*World -> *(a, !*World))
In Haskell, it is:

    newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))
(for full context see: http://hackage.haskell.org/package/ghc-prim-0.5.3/docs/src/G..., the related monad instance is here: http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GH...)

These both implement IO as a function which takes the state of the world as its input and returns a new state of the world as it's output. This is encoded using the state transformation that I mention in the other post (https://acm.wustl.edu/functional/state-monad.php) Both implementations also go on to define Monad instances for their new IO type. The major difference is that the Haskell standard library only exposes bindIO and returnIO to the user and hides the internals of IO from the user and Clean allows the implementation to be a normal library.

That difference is Clean's uniqueness types showing their strength. Clean can explicitly expose it's predefined World type (https://cloogle.org/doc/#CleanRep.2.2_6.htm;jump=_Toc3117980...) to the user with the guarantee that you can't write a function of type IO a -> a because it would violate the uniqueness properties and thus be a compilation error. Haskell instead uses the module system to keep State# RealWorld from being exposed to the user. This means that if you as a user want a different set of abstractions for impurity in Clean, you can build from the World level rather than needing to construct it out of what can be done with bindIO and returnIO. For details on what's going on with State# see https://www.fpcomplete.com/blog/2015/02/primitive-haskell

From the perspective of "the value prop for learning/using monads", this discussion leaves us in a worse place than where we started because the conclusion is that uniqueness types aren't a get out of monads free card and that Clean uses the many of the same Monad-related abstractions as Haskell does and uses them for the same purposes. In order to not leave you out in the cold as to the value prop for the monad abstraction, you can see how it works for a number of different Monad instances in Tikhon's answer on Quora (https://www.quora.com/What-are-monads-in-functional-programm...), though he chooses to use join, fmap, and return as the fundamental parts of a Monad, rather than bind and return, as I have here. As he touches on in his discussion, it's common and straightforward to implement one definition in terms of the other, so anything you learn from about that definition can be ported the definition I use without much fuss, so don't worry if it doesn't match at first. What this means is that if you have a tools in the standard library that only depend on features of Monad, you can use the same small collection of functions to solve a ton of problems.

Post reply on HN