Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:02:49+00:00 2026-06-01T19:02:49+00:00

I am not so familiar with forall , but recently read this question: What

  • 0

I am not so familiar with forall, but recently read this question: What does the `forall` keyword in Haskell/GHC do?

In one of the answers is this example:

 {-# LANGUAGE RankNTypes #-}
 liftTup :: (forall x. x -> f x) -> (a, b) -> (f a, f b)
 liftTup liftFunc (t, v) = (liftFunc t, liftFunc v)

The explanation is good and I understand what forall is doing here. But I’m wondering, is there a particular reason why this isn’t the default behaviour. Is there ever a time where it would be disadvantageous?

Edit: I mean, is there are a reason why the forall’s can’t be inserted by default?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:02:50+00:00Added an answer on June 1, 2026 at 7:02 pm

    Well, it’s not part of the Haskell 2010 standard, so it’s not on by default, and is offered as a language extension instead. As for why it’s not in the standard, rank-n types are quite a bit harder to implement than the plain rank-1 types standard Haskell has; they’re also not needed all that frequently, so the Committee likely decided not to bother with them for reasons of language and implementation simplicity.

    Of course, that doesn’t mean rank-n types aren’t useful; they are, very much so, and without them we wouldn’t have valuable tools like the ST monad (which offers efficient, local mutable state — like IO where all you can do is use IORefs). But they do add quite a bit of complexity to the language, and can cause strange behaviour when applying seemingly benign code transformations. For instance, some rank-n type checkers will allow runST (do { ... }) but reject runST $ do { ... }, even though the two expressions are always equivalent without rank-n types. See this SO question for an example of the unexpected (and sometimes annoying) behaviour it can cause.

    If, like sepp2k asks, you’re instead asking why forall has to be explicitly added to type signatures to get the increased generality, the problem is that (forall x. x -> f x) -> (a, b) -> (f a, f b) is actually a more restrictive type than (x -> f x) -> (a, b) -> (f a, f b). With the latter, you can pass in any function of the form x -> f x (for any f and x), but with the former, the function you pass in must work for all x. So, for instance, a function of type String -> IO String would be a permissible argument to the second function, but not the first; it’d have to have the type a -> IO a instead. It would be pretty confusing if the latter was automatically transformed into the former! They’re two very different types.

    It might make more sense with the implicit foralls made explicit:

    forall f x a b. (x -> f x)           -> (a, b) -> (f a, f b)
    forall f a b.   (forall x. x -> f x) -> (a, b) -> (f a, f b)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very familiar with RoR but my colleague has written this code
I'm not familiar with eclipse. I have a question as this topic title. The
This is what I am trying to achieve but I'm not familiar with the
I'm not familiar with Capistrano at all, I've just read some basic posts about
I'm not familiar on how forms work. Example Scenario Lets say users can create
I'm not familiar with ADO.NET Data Services but it looks usable. All I need
I'm not overly familiar with the SQL Server data dictionary, but I've assumed what
I'm not familiar with the field, so please excuse me if the question seems
Im not very familiar with refactoring but I feel like I need to do
I'm not familiar with wpf or C# language, but I want to generate xaml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.