Re:Generalized Algebraic Data Types: A Primer
by skybrian on Tuesday June 18, 2019 @11:12PM
(#20220512)
This is interesting, but several of the examples are useless (such as HList) or might not be a good idea in practice. Sometimes that's an easier way to explain a concept, but it would be helpful to see more examples that show you techniques that are actually recommended, rather than what not to do.
Re:Generalized Algebraic Data Types: A Primer
by whateveracct on Wednesday June 19, 2019 @02:57AM
(#20221349)
HLists actually aren't _useless_ in practice. I know I've used shapeless to do some datatype-generic programming with them (deriving CSV rows from a case class without reflection.)
Heterogenous unions are very similar and also extremely useful (multiple effects libraries build on top of them).
Re:Generalized Algebraic Data Types: A Primer
by dan-robertson on Wednesday June 19, 2019 @05:00AM
(#20221832)
Well HList gives you something which behaves like a tuple with generic size. The difference between an HList and a type like (a * (b * (c * unit))) is that the HList can use the regular list syntax which is much nicer to match on (especially with type constructor disambiguation). Eg one could imagine a varadic list map function which behaves a bit like map in lisps (ie accepting any positive number of lists). Although this would need multiple types that look like lists because of the lack of higher kinded types in reason/ocaml
Re:Generalized Algebraic Data Types: A Primer
by antisemiotic on Wednesday June 19, 2019 @02:54AM
(#20221338)
>several of the examples are useless (such as HList)
I tried to use a similar (though more streamlined) Vinyl [1] for implementing database querying that glued and sliced records to match the queries, but alas, GHC choked and died on the type-level list operations. That was several years ago though and I didn't touch Haskell since then, maybe something has changed.
Re:Generalized Algebraic Data Types: A Primer
by hardwaresofton on Tuesday June 18, 2019 @09:58PM
(#20220212)
I find the GADT syntax used in the article hard to follow... Normally this is what I see, straight out of Jannis Limperg's insanely helpful compilation of language extension examples[0]:
data RestrictedMaybe a where
JustInt :: Int -> RestrictedMaybe Int
JustString :: String -> RestrictedMaybe String
Nothing :: RestrictedMaybe a
Maybe the intention was more of a "from scratch" implementation (without using extensions) but the above syntax is a bit easier to follow in my opinion IMO.
It might also be a good idea to make note of where the polymorphism is happening (the "a") and note how it's ok that the a is "resolved" in some of these constructors but not in the others.
Re:Generalized Algebraic Data Types: A Primer
by andywhite37 on Tuesday June 18, 2019 @06:20PM
(#20219036)
It's probably a free-tier heroku app, being hugged to death right now. I've used this site quite a bit in the past on FireFox, Chrome, and Brave, and it has worked perfectly before.
Re:Generalized Algebraic Data Types: A Primer
by thangngoc89 on Tuesday June 18, 2019 @07:13PM
(#20219390)
Thank you. Like you said, I use Firefox for development and test it on Chrome as well.
The target users of Sketch.sh is web developers so I received bug reports about browser incompatibility almost instantly.
It was a problem with now.sh version 1 platform. I can't find a way to scale the free v1 node. All their docs prefer to upgrading to version 2 platform.
Re:Generalized Algebraic Data Types: A Primer
by quickthrower2 on Wednesday June 19, 2019 @06:06AM
(#20222089)
This is forgivable because you can fork and edit it. Once you go from reading to editing, it is useful to see the markup. Many of us are used to reading verbatim markdown if your team uses readme.md in the git repo root of projects.
Re:Generalized Algebraic Data Types: A Primer
by molyss on Tuesday June 18, 2019 @10:11PM
(#20220261)
On my iphone, I can’t jump to the links, and if I try to select a URL, it switches to edit mode and I can’t even switch tabs because the keyboard is constantly taking over.
I was interested by the title but will skip the article because of poor UI
Heterogenous unions are very similar and also extremely useful (multiple effects libraries build on top of them).
I tried to use a similar (though more streamlined) Vinyl [1] for implementing database querying that glued and sliced records to match the queries, but alas, GHC choked and died on the type-level list operations. That was several years ago though and I didn't touch Haskell since then, maybe something has changed.
[1] https://hackage.haskell.org/package/vinyl
It might also be a good idea to make note of where the polymorphism is happening (the "a") and note how it's ok that the a is "resolved" in some of these constructors but not in the others.
[0]: https://limperg.de/ghc-extensions/#gadts
On a similar note i find the OCaml syntax easier to read than Reason's. (There is an option to toggle between the two in the linked website)
The example from your post in OCaml:
Another kind of HN hug of death
You all can view the Sketch. Apology for the inconvenient.
The target users of Sketch.sh is web developers so I received bug reports about browser incompatibility almost instantly.
It was a problem with now.sh version 1 platform. I can't find a way to scale the free v1 node. All their docs prefer to upgrading to version 2 platform.
really though, this is a comfortable experience and the seamless live-coding environment feels natural. nice work!
I was interested by the title but will skip the article because of poor UI