Skip to content

Rank 2 Polymorphism Compile Error

Not sure if this is a bug, perhaps this should be a feature request.

Given the following code:

{-# LANGUAGE Rank2Types #-}

import Control.Monad.ST
import Data.STRef

fourty_two :: forall s. ST s Int
fourty_two = do
  x <- newSTRef (42::Int)
  readSTRef x

main = (print . runST) fourty_two -- (1)
main = (print . runST) $ fourty_two -- (2)
main = ((print . runST) $) fourty_two -- (3)

(1) and (3) compile successfully, but (2) does not. I'm not sure why this is the case.

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Windows
Architecture x86_64 (amd64)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information