Skip to content

-fsolve-constant-dicts is not very robust when dealing with GADTs

I expected -fsolve-constant-dicts to nail #9701, it didn't fire at all but a slightly modified version does.

{-# LANGUAGE GADTs #-}    
{-# LANGUAGE TypeApplications #-}    
module Foo where    
      
data Silly a where    
  Silly :: Ord a => a -> Silly a    
      
isItSilly :: a -> Silly a -> Bool    
isItSilly a (Silly x) = a < x    

isItSillyIntTA :: Int -> Silly Int -> Bool
isItSillyIntTA = isItSilly @Int
      
isItSillyInt :: Int -> Silly Int  -> Bool    
isItSillyInt  a x = isItSilly a x    
      
isItSillyInt2 :: Int -> Silly Int -> Bool    
isItSillyInt2 a (Silly x) = a < x          
                                                                                
isItSillyInt3 :: Int -> Silly Int -> Bool                                     
isItSillyInt3 a (Silly x) = isItSilly a (Silly x)

Both versions 2 and 3 specialise nicely using the Int Ord dictionary. The first two versions don't. I'm unsure whether it *should* fire or not but I am making this ticket to record this fact.

Clonable code and core dump - https://gist.github.com/mpickering/f84a5f842861211e8e731c63e82d5c01

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