Skip to content

Instantly share code, notes, and snippets.

@brainrake
Last active November 30, 2018 16:56
Show Gist options
  • Save brainrake/b9e591173d27afa23f42d717c936a9bc to your computer and use it in GitHub Desktop.
Save brainrake/b9e591173d27afa23f42d717c936a9bc to your computer and use it in GitHub Desktop.
idris type-directed overloading
f : String -> String
f x = x ++ "!"
namespace maybe
f : Maybe String -> String
f (Just x) = x ++ "!"
f Nothing = "_"
test1 : String
test1 = f "foo"
test2 : String
test2 = f (Just "bar")
test3 : String
test3 = f Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment