Skip to content

Typechecking fails for parallel monad comprehensions with polymorphic let (GHC 7.10.3 through 8.6.3)

{-# LANGUAGE MonadComprehensions, ParallelListComp #-}

module Foo where

foo xs ys = [ (f y True, f x 'c')
            | let f _ z = z, x <- xs
            | y <- ys ]

This fails with

Foo.hs:5:52: error:
    * Cannot instantiate unification variable `t0'
      with a type involving foralls: forall t2 t3. t3 -> t2 -> t2
        GHC doesn't yet support impredicative polymorphism
    * In a stmt of a monad comprehension:
        let f _ z = z, x <- xs |  y <- ys
      In the expression:
        [(f y True, f x 'c') | let f _ z = z, x <- xs |  y <- ys]
      In an equation for `foo':
          foo xs ys
            = [(f y True, f x 'c') | let f _ z = z, x <- xs |  y <- ys]

NB: ApplicativeDo has a related problem: the implementation is quite different and has the effect of monomorphising the let-bound variable.

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