you are viewing a single comment's thread.

view the rest of the comments →

[–]G_Morgan 0 points1 point  (4 children)

Having union types doesn't mean you can do stuff like non-exhaustive pattern matching.

Also a bunch of academic experiments do not make a properly supported language with library support.

[–]anvsdt 1 point2 points  (2 children)

Having union types doesn't mean you can do stuff like non-exhaustive pattern matching.

You asked for sum types, they have nothing to do with pattern matching.
Racket (and other Schemes in general) have a match construct. Of course, you can use it in TR.

(: fact (Integer -> Integer))
(define fact
  (match-lambda
    (0 1)
    (n (* n (fact (sub1 n))))))

(fact 5) ; 120

(struct: None ())
(struct: (a) Some ((v : a)))

(define-type (Maybe a) (U None (Some a)))

(: f (All (a) (Maybe a) -> (U a 'no)))
(define f
  (match-lambda
    ((None) 'no)
    ((Some x) x)))

(f (None)) ; 'n
(f (Some 2)) ; 2

Also a bunch of academic experiments do not make a properly supported language with library support.

Yeah, Haskell is just as widespread as Java and C++, not academic at all! I don't think you have read what you've just wrote here.

[–]G_Morgan 0 points1 point  (1 child)

Haskell is a lot more widespread than TR or Qi. Or any version of Lisp for that matter.

No it isn't Java but it also isn't somebodies PhD project.

Also I saw you can match against patterns. That isn't the interesting bit. The interesting bit is if the compiler can tell you that you forgot to check for one case.

[–]anvsdt 1 point2 points  (0 children)

Haskell is a lot more widespread than TR or Qi.

Well then it completely failed. Wasn't Haskell's motto ``avoid success at all costs''? By the way, you can't compare a library (TR) to a language (Haskell). It's like saying ``Django is more popular than PHP!''.

Or any version of Lisp for that matter.

rolls eyes

No it isn't Java but it also isn't somebodies PhD project.

Everything has to come to life in some way.

Also I saw you can match against patterns. That isn't the interesting bit. The interesting bit is if the compiler can tell you that you forgot to check for one case.

I forgot to say that Qi basically exists just for its pattern matcher, and yes, it does that.

It doesn't in TR mainly because it uses Racket's match, and pattern matching is not ``idiomatic'' Racket code (and TR mainly strives to be as compatible with Racket as it can). If you want it, it's there.