[Haskell-cafe] Where are rank-3 types necessary in practice for maintaining abstraction?

David Feuer david.feuer at gmail.com
Wed Apr 4 03:35:35 UTC 2018


Take a look at this PR:

https://github.com/haskell/primitive/pull/109/files

The heterogeneous array creation functions I propose take rank-2 traversal
functions as arguments and are therefore rank-3. In this case, the reason
is a bit boring: the package in question can't depend on either (any?) of
the packages offering rank-2 versions of Traversable.

On Tue, Apr 3, 2018, 6:37 AM Timotej Tomandl <timotomandl at gmail.com> wrote:

> Hello,
>
> So we need rank-2 type in runST :: (forall s. ST
> <https://hackage.haskell.org/package/base-4.11.0.0/docs/Control-Monad-ST.html#t:ST>
> s a) -> a, to prevent s from appearing in a.
>
> I have been thinking about this for a bit, but I failed to come up with a
> practical situation, where rank-3 types are necessary for safety of some
> abstraction.
>
> The rank-3 example in here and any other I found, look very synthetic,
> i.e. limiting computation to id:
> https://ocharles.org.uk/blog/guest-posts/2014-12-18-rank-n-types.html
> and compared to the runST example of limiting a scope of a type variable
> for purposes of safety looks unnatural.
> Could anyone please point me to a practical example of rank-3
> polymorphism, where it is necessary for safety of an abstraction, if it
> exists?
>
> I suspect there is a situation, where rank-3 is necessary for maintaining
> abstration exists, but I can't think of any.
> Any ideas about such situations and even better situations where this is
> used on hackage?
>
> Timotej Tomandl
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180404/f84efd36/attachment.html>


More information about the Haskell-Cafe mailing list