Skip to content

Instantly share code, notes, and snippets.

@nicuveo
Created Jan 27, 2021
Embed
What would you like to do?
Repro case for redundant constraint bug.
all:
ghc --version
ghc -Wredundant-constraints -Werror -O0 Main.hs
ghc -Wredundant-constraints -Werror -O2 Main.hs
make
ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.2
ghc -Wredundant-constraints -Werror -O0 Main.hs
Loaded package environment from /home/nicuveo/.ghc/x86_64-linux-8.10.2/environments/default
[1 of 1] Compiling Main ( Main.hs, Main.o )
Linking Main ...
ghc -Wredundant-constraints -Werror -O2 Main.hs
Loaded package environment from /home/nicuveo/.ghc/x86_64-linux-8.10.2/environments/default
[1 of 1] Compiling Main ( Main.hs, Main.o ) [flags changed]
Main.hs:12:1: error: [-Wredundant-constraints, -Werror=redundant-constraints]
• Redundant constraint: Show Int
• In the type signature for:
foo :: Show Int => Int -> IO ()
|
12 | foo :: Show Int => Int -> IO ()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
make: *** [Makefile:4: all] Error 1
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
bar :: forall a. Show a => a -> IO ()
bar = print
foo :: Show Int => Int -> IO ()
foo = bar
main :: IO ()
main = foo 42
@jberryman
Copy link

jberryman commented Jan 27, 2021

Can repro on the 9.1.20201218 ghc I'm using too

@nicuveo
Copy link
Author

nicuveo commented Jan 27, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment