Created
April 12, 2022 09:40
-
-
Save gdeest/a60c90cdf4e80ae50199e6a750881912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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