Skip to content

Instantly share code, notes, and snippets.

@nicuveo
Created January 27, 2021 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicuveo/0999e67639123d05b6e5b6c391cfc53f to your computer and use it in GitHub Desktop.
Save nicuveo/0999e67639123d05b6e5b6c391cfc53f to your computer and use it in GitHub Desktop.
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

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