Skip to content

Instantly share code, notes, and snippets.

@asterite
Created August 26, 2015 17:46
Show Gist options
  • Save asterite/05e9e1fafa683431a510 to your computer and use it in GitHub Desktop.
Save asterite/05e9e1fafa683431a510 to your computer and use it in GitHub Desktop.
module Moo
# Moo expects `foo` to return an Int32
abstract def foo : Int32
# `bar` adds 1 to it
def bar : Int32
foo + 1
end
# And maybe it provides other methods...
def bar2
42
end
end
# MooImpl decides inovking "foo" is an error. A real example
# is an IO which is read-only and raises in the
# `write(slice, count)` method.
class MooImpl
def foo
raise "Not implemented"
end
end
# The above will make `bar` have the type `NoReturn`, but it should still compile,
# even though NoReturn != Int32.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment