Skip to content

Commit

Permalink
Overlapping instances
Browse files Browse the repository at this point in the history
  • Loading branch information
steshaw committed Jun 25, 2023
1 parent 09eeac5 commit 23aa64c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions overlapping.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--
-- See https://serokell.io/blog/learn-from-errors-overlapping-instances
--

class printable (a: Type) :=
( print_me : a -> IO Unit )

instance printable_a : printable a :=
printable.mk (fun _ => IO.println "dummy instance")

instance printable_int: printable Nat where
print_me n := IO.println $ s!"I am an Int with value {n}"

def main := do
printable.print_me "hi"
printable.print_me 5

0 comments on commit 23aa64c

Please sign in to comment.