News for hackers. Stuff that matters.
Re:Examples of Incorrect Abstractions in Other Languages by christophilus on Tuesday May 19, 2020 @06:14PM (#23240933)
> And yet, for a long time, it lacked a function analogous to <>, which is strange when considered from a "folds are Applicative" perspective.

Man. I enjoyed hacking around with Haskell back in the day, but I found it to be a write only language with forms like <> making me stop and stare too often.

Also, after maybe 15 years of working in statically typed languages, I also decided that ultimately, I prefer dynamically typed languages. Still have yet to use my favorite (Clojure) in production, though.

Re:Examples of Incorrect Abstractions in Other Languages by outworlder on Tuesday May 19, 2020 @07:00PM (#23241327)
> Also, after maybe 15 years of working in statically typed languages, I also decided that ultimately, I prefer dynamically typed languages. Still have yet to use my favorite (Clojure) in production, though.

I like to have types when I need types. If I want to write a numeric value in a json output I'm creating that will be consumed by some other system, I want that thing to represent exactly that and spit an error if I ever try to assign something else, such as a string. But more than that, it should be easy to define my own types. I need to be able to say, "this number is not just any number, this is actually a temperature measurement in Celsius" or "this is talking about screen coordinates, not world coordinates". And then only be able to send that to the correct functions – or treat as a normal number if I'm doing basic math.

But most of the time, most people don't care about types. We want to say "do this operation across all elements of this array". If I trust whatever lower level function that added the properly typed elements in the first place, now I can focus on manipulating them. Glue code is very amenable to dynamic types.

Haskell has a very rich type system (maybe too rich?), but it also allows you to say that function receives an A and returns [A]. What's A? If you don't care, you don't care. That's beautiful. And the compiler can even inference some of it for you.

Now, if the only thing I have is a poor type system(like Java), then just give me primitives and a struct.

Re:Examples of Incorrect Abstractions in Other Languages by JCoder58 on Tuesday May 19, 2020 @07:42PM (#23241662)
You want F#.

> If I want to write a numeric value in a json output I'm creating that will be consumed by some other system, I want that thing to represent exactly that and spit an error if I ever try to assign something else, such as a string

https://fsharpforfunandprofit.com/posts/serializating-your-d...

> I need to be able to say, "this number is not just any number, this is actually a temperature measurement in Celsius"

https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...

Re:Examples of Incorrect Abstractions in Other Languages by whateveracct on Tuesday May 19, 2020 @08:22PM (#23241979)
<> is not write-only

Just because you used + in grade school doesn't mean it's more intuitive than <>. Your child brain could learn + so your adult one can learn <>

The code I work with professionally that makes heavy use of <>, <*>, <$>, and >>= is usually the easiest parts of the codebase.

I'm not mathematician. I didn't go to a fancy private school. I didn't learn FP or category theory formally.

Re:Examples of Incorrect Abstractions in Other Languages by tome on Wednesday May 20, 2020 @02:53AM (#23244027)
OP meant <*> but HN ate the star as an italic character
Re:Examples of Incorrect Abstractions in Other Languages by whateveracct on Wednesday May 20, 2020 @04:40PM (#23251508)
Ah ok. Well then I'd use multiplication as the analogy there. It was slightly abstract for my child brain but opened up so many possibilities. Applicatives feel like the adult version of that.
Re:Examples of Incorrect Abstractions in Other Languages by bedobi on Tuesday May 19, 2020 @06:47PM (#23241209)
Have a look at Kotlin with the Arrow library, it's a great compromise