Skip to content

Instantly share code, notes, and snippets.

@i-am-tom
Created September 22, 2020 20: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 i-am-tom/7de3e07279026e73f9cf68737b8ca6be to your computer and use it in GitHub Desktop.
Save i-am-tom/7de3e07279026e73f9cf68737b8ca6be to your computer and use it in GitHub Desktop.
A warning to all
{-# LANGUAGE DataKinds #-}
{-# LANguAGE FlexibleContexts #-}
{-# LAnguaGE FlexibleInstances #-}
{-# LanguagE KindSignatures #-}
{-# language MultiParamTypeClasses #-}
import GHC.TypeLits (Symbol)
class Warning (message :: Symbol) x
instance Warning (message :: Symbol) x
f :: Warning "We should refactor this!" x => x -> x
f = id
-- Main.hs:12:6-51: warning: [-Wsimplifiable-class-constraints]
-- • The constraint ‘Warning "We should refactor this!" x’ matches
-- instance Warning message x -- Defined at Main.hs:10:10
-- This makes type inference for inner bindings fragile;
-- either use MonoLocalBinds, or simplify it using the instance
-- • In the type signature:
-- f :: Warning "We should refactor this!" x => x -> x
-- |
-- 12 | f :: Warning "We should refactor this!" x => x -> x
-- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment