Skip to content

QuantifiedConstraints runtime loopiness -- simplifier ticks(?)

Consider these QuantifiedConstraints aimed at reinforcing a FunDep (from this comment)

{-# LANGUAGE  QuantifiedConstraints, {- etc -} #-} 

class (forall b. F Int    b => b ~ Bool,
       forall b. F String b => b ~ Char )
      => F a b  | a -> b

instance F Int    Bool
instance F String Char

class D a where { op :: F a b => a -> b }

instance D Int    where { op _ = True }
instance D String where { op _ = 'c' }

This compiles OK, no warnings with -Wall set.

*> :t op "hello"
op "hello" :: Char
*>  op "hello"                              -- runs forever
[^C]Interrupted.

I see no reason this should be looping: op doesn't inspect its argument, just returns a literal.

On GHC 8.6.4 and 8.6.1; Windows platform.

Edited by Anthony Clayden
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information