[Haskell-cafe] Infinite types should be optionally allowed

Job Vranish jvranish at gmail.com
Fri Feb 13 17:13:13 EST 2009


There are good reasons against allowing infinite types by default
(mostly, that a lot of things type check that are normally not what we
want). An old haskell cafe conversation on the topic is here:
http://www.nabble.com/There%27s-nothing-wrong-with-infinite-types!-td7713737.html

However, I think infinite types should be allowed, but only with an
explicit type signature. In other words, don't allow infinite types to
be inferred, but if they are specified, let them pass. I think it
would be very hard to shoot yourself in the foot this way.

Newtype is the standard solution to situations where you really need
an infinite type, but in some cases this can be a big annoyance. Using
newtype sacrifices data type abstraction and very useful type classes
like Functor. You can use multiparameter type classes and functional
dependencies to recover some of the lost abstraction, but then type
checking becomes harder to reason about and the code gets way more
ugly (If you doubt, let me know, I have some examples). Allowing
infinite types would fix this.

I'm imagining a syntax something like this:
someFunctionThatCreatesInfiniteType :: a -> b | b = [(a, b)]

Thoughts? Opinions? Am I missing anything obvious?

- Job


More information about the Haskell-Cafe mailing list