Skip to content

Instantly share code, notes, and snippets.

@gdeest
Created April 12, 2022 09:40
Show Gist options
  • Save gdeest/a60c90cdf4e80ae50199e6a750881912 to your computer and use it in GitHub Desktop.
Save gdeest/a60c90cdf4e80ae50199e6a750881912 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
class Foo a b
instance Foo Int ()
newtype BarInt = Bar Int
-- This doesnt work because BarInt is _not_ the last type class parameter.
-- deriving newtype instance Foo BarInt ()
class Foo a b => FlippedFoo b a
instance {-# OVERLAPPING #-} FlippedFoo b BarInt => Foo BarInt b
deriving newtype instance FlippedFoo () BarInt
bleh :: Foo BarInt () => ()
bleh = ()
main :: IO ()
main = print bleh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment