Skip to content

Instantly share code, notes, and snippets.

@i-am-tom

i-am-tom/Main.hs

Created Sep 22, 2020
Embed
What would you like to do?
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