Switching on TypeFamilies extension stops code from typechecking
The following code has the TypeFamilies
extension enabled but does not use it. It does not typecheck with GHC 7.8.3. If we do not enable TypeFamilies
(i.e. delete the first line) it typechecks.
{-# LANGUAGE TypeFamilies #-}
module ExistentialFamilies where
import Control.Monad.ST (runST,ST)
un :: ()
un = runST f where
f = return un :: ST s ()
This happens when trying to compile the program as well as when trying to load it into ghci.
The error message when TypeFamilies
is on is
> ghc ExistentialFamilies.hs
[1 of 1] Compiling ExistentialFamilies ( ExistentialFamilies.hs, ExistentialFamilies.o )
ExistentialFamilies.hs:7:12:
Couldn't match type ‘s0’ with ‘s’
because type variable ‘s’ would escape its scope
This (rigid, skolem) type variable is bound by
a type expected by the context: ST s ()
at ExistentialFamilies.hs:7:6-12
Expected type: ST s ()
Actual type: ST s0 ()
Relevant bindings include
f :: ST s0 () (bound at ExistentialFamilies.hs:8:5)
In the first argument of ‘runST’, namely ‘f’
In the expression: runST f