Reputation
984
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
1 5 7
Impact
~19k people reached

  • 0 posts edited
  • 0 helpful flags
  • 4 votes cast
Aug
8
awarded  Great Answer
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat Yes, Haskell disallows this. Every call to a constructor (not that they exist) would produce a structurally equivalent object. They may not have any equality at all, but if one is defined it can be no more fine than one which respects referential transparency.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat sorry, I should have been explicit, in this example mk is a pure function. It returns identical objects by virtue of computing them identically, but they're different objects by virtue of them not necessarily being at the same memory address. Equational semantics must respect the first (indeed that is more or less definitional) but must ignore the second. If f can detect sharing then it violates referential transparency and violates equational reasoning.
Aug
7
awarded  Commentator
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat Sure, if f is a function which potentially examines its arguments to see that they're they have reference equality then the operation f(mk(), mk()) ===> let x = mk() in f(x, x) is an invalid transformation.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat If you throw away referential transparency it's not that you lose power (in fact you gain it, certainly) but instead that you lose the ability to reason equationally. This is important for human faculties but also for compiler transforms and optimizations.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
I wrote a series of blog posts on this actually a little while back: jspha.com/posts/mutable_algorithms_in_immutable_languges_part_1
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
This isn't to say that such algorithms are impossible to write or use in Haskell... it's just that the base semantics doesn't offer them. Instead, you need to use monadically augmented semantics via something like ST.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat Additionally, there's no way to have referential transparency and allow for analysis of self-referential graphs. If you can identify whether two references point to the same place then you are exactly violating referential transparency.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat As Paul notes there is no sense of object equality ("reference equality") in Haskell excepting where you explicitly create your own via tags (and then are personally responsible for ensuring equality behaves properly). In fact, there are types in Haskell which have no (internal) notion of equality at all!
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat I'm not confident that I understand your terminology. I'd suggest that many mutual reference situations are handled in Haskell through laziness and "tying the knot", but it is true that some mutual references are more clearly stated by explicit mutation. The ST monad can be used to accomplish this.
Aug
7
comment What exactly makes the Haskell type system so revered (vs say, Java)?
@supercat Haskell lacks reference semantics entirely (this is the notionn of referential transparency which entails that everything is preserved by replacing references with their referents). Thus, I think your question is ill-posed.
Aug
7
awarded  Yearling
Apr
24
awarded  Guru
Apr
22
awarded  Yearling
Apr
17
comment What exactly makes the Haskell type system so revered (vs say, Java)?
That's just straight quoted from Tony Hoare: en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retractions. While I'm sure there are times when null is necessary in pointer arithmetic, I instead interpret that to say that pointer arithmetic is a bad place to host the semantics of your language not that null isn't still a mistake.
Apr
17
awarded  Good Answer
Apr
17
awarded  Mortarboard
Apr
17
revised What exactly makes the Haskell type system so revered (vs say, Java)?
added 775 characters in body
Apr
17
revised What exactly makes the Haskell type system so revered (vs say, Java)?
added 85 characters in body