Making illegal states unrepresentable without access to at least HKTs and preferrably also to GADTs and type families is so limited that it becomes almost futile. Or becomes very verbose in a similar way to having no polymorphism/“generics”. #fsharp#Haskell#ddd
Here is a type for a customer and address in pseudo-#fsharp syntax: type Customer f = Customer of Name * f<Adress>. Newly registered customer may or may not enter an address: register : ... -> Customer Option. But...
... placing an order requires the address to be known: placeOrder : ... -> Customer<Identity> -> Order. Where type Identity<a> = a.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
I write #fsharp and #haskell daily (and #purescript too) and thought of making a micro-blog comparison of the two. Fun facts and maybe new discoveries for the interested, in no particular order. This will be long and probably slow.
Unlike #fsharp, #haskell has no records, only discriminated unions. It does have something called “record syntax” for DUs.
In #fsharp functions cannot be overloaded. In #haskell it is possible through the “type classes” mechanism, conceived specifically for this.