5 ms·
I encountered HM a lot in my working life as a programmer. I did not expect that when I first encountered the names. From the article: > HM type systems can't
by cies 2y ago
I encountered HM a lot in my working life as a programmer. I did not expect that when I first encountered the names.
From the article:
> HM type systems can't implement heterogenous lists [...]
> [well it does when wrapping the elements in a sum type, but then]
> it can only accept types you know about in advance.
> [which makes it] a massive pain to work with.
Sorry, I totally disagree... Heterogeneous lists without the sum types are a massive pain! Maybe it is easier for the initial development effort, but if you need to maintain code with heterogeneous lists (or dynamically typed code in general) the pain will come at some point and likely when already in production.
I much rather fix compile errors than runtime errors. And a massive thanks to Hindley and Milner for advancing type systems!
Found their photos in gratitude just now:
https://www.researchgate.net/profile/J-Hindley https://www.researchgate.net/profile/J-Hindley
https://en.wikipedia.org/wiki/Robin_Milner https://en.wikipedia.org/wiki/Robin_Milner
- fluoridation 2y agoThey're only a pain if you need to know the run-time types of the elements. If you're just operating on them through a narrowly defined interface, that's just dynamic polymorphism, which is indeed more flexible with regards to future expandability, as long as you define the interface appropriately.
- deleted 2y ago[deleted]
- cies 2y ago> as long as you define the interface appropriately Well, if you have an interface that all entries adhere to it is not a heterogeneous list in my book. In Haskell that could be achieve without a sum type wrapper, but with a type class. https://fluoridealert.org/key-topics/tsca-fluoride-lawsuit/ https://fluoridealert.org/key-topics/tsca-fluoride-lawsuit/
- fluoridation 2y agoI mean, a heterogeneous list is literally a list where its elements may be of different types. To use a tired example, if a list that contains both a Cat and a Dog is not heterogeneous just because both adhere to the Mammal interface, then what is a heterogeneous list?
- philh 2y agoI think my position is: Native heterogeneous lists will often be convenient, and sometimes when you've used them they're going to turn out in retrospect to have been a bad idea but sometimes they'll be just fine, especially if they stay fairly locally scoped. I haven't done any serious work in a language that supports them for years, so I don't have a strong opinion about how often each of those cases happens. But if you decide you want heterogeneous lists, but your language doesn't support them, so you try to implement that with a sum type, then that's basically always going to be a massive pain.
- cies 2y ago> I haven't done any serious work in a language that supports them for years Is this not silently admitting that strong types to some degree have won? Don't get me wrong: I like Clojure/LISPs/Ruby. But I would not choose them for a new project these days. (and I do not like JS, which has them too)
- philh 2y agoI'm still working at the same company as when I wrote this, and that company is still using Haskell (now mostly Typescript instead of Elm). If I did move on I'd ideally want to keep using Haskell, or failing that some other strongly typed language. But I don't expect that my own experience says much about the language ecosystem in general. I don't particularly have an opinion on whether or not strong types have "won", and I didn't intend to comment on that question.
- freilanzer 2y agoI would definitely choose a Lisp if it had an Intellij-like IDE. Especially since the type system of CL is good, though not static, obviously. But it's a tradeoff between having Haskell during compile time and CL during development time, for me.
- yawaramin 2y agoWhat's an example use case where heterogeneous lists turn out to be fine but can't be modelled with eg the OCaml difflist technique, eg https://github.com/yawaramin/re-web/blob/0d6c62fb432f85cc43757c46849df8b75985199b/ReWebTest/FormTest.ml#L9 https://github.com/yawaramin/re-web/blob/0d6c62fb432f85cc437... ?