Generalized Algebraic Data Types: A Primer
sketch.sh
sketch.sh
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.
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.
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:
type 'a restricted_maybe =
| JustInt : int -> int restricted_maybe
| JustString : string -> string restricted_maybe
| Nothing : 'a restricted_maybeAnother 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