The language extension ExplicitForall makes it possible but not required to bind type variables with forall.
For example, the following program compiles
{-# LANGUAGE ExplicitForAll #-}
-- cps1.hs
-- non-cps definition of add
add :: Int -> Int -> Int
add x y = x + y
-- cps definition of add
add_cps :: forall r . Int -> Int -> (Int -> r) -> r
add_cps x y k = k (add x y)
However, the following program without an explicit quantifier for r also compiles.
{-# LANGUAGE ExplicitForAll #-}
-- cps2.hs
-- non-cps definition of add
add :: Int -> Int -> Int
add x y = x + y
-- cps definition of add
add_cps :: Int -> Int -> (Int -> r) -> r
add_cps x y k = k (add x y)
Is there some combination of language extensions or compiler flags that can make the second program fail to compile?
No, GHC currently does not have tooling for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With