Skip to content

Instantly share code, notes, and snippets.

@exarkun
Created January 21, 2021 20:13
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 exarkun/46b122be66467b2f11a526ed1e537ad1 to your computer and use it in GitHub Desktop.
Save exarkun/46b122be66467b2f11a526ed1e537ad1 to your computer and use it in GitHub Desktop.
class X x where
a :: x -> Int
data AnX = AnX Int
instance X AnX where
a (AnX v) = v
class Y y where
b :: y -> Int
data AnY = AnY Int
instance Y AnY where
b (AnY v) = v
instance Y y => X y where
a anY = b anY
foo :: X x => x -> Int
foo x = a x
main :: IO ()
main =
let
anX = AnX 5
anY = AnY 6
in do
print (foo anX)
print (foo anY)
/home/exarkun/Work/haskell/tahoe-lafs-immutable-uploader/aesctr/Main.hs:68:10: error:
• The constraint ‘Y y’ is no smaller than the instance head ‘X y’
(Use UndecidableInstances to permit this)
• In the instance declaration for ‘X y’
|
68 | instance Y y => X y where
| ^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment