Skip to content

Instantly share code, notes, and snippets.

@edwinb
Last active August 29, 2015 14:13
Show Gist options
  • Save edwinb/1bd96cb729774dd382ef to your computer and use it in GitHub Desktop.
Save edwinb/1bd96cb729774dd382ef to your computer and use it in GitHub Desktop.
Scoped implicits and type classes
AnyST : Type -> Type -> Type
AnyST s a = {m : _} -> Monad m => StateT s m a
foo : AnyST Integer ()
foo = do x <- get
put (x + 1)
wibble : StateT Integer Maybe ()
wibble = foo
appShow : Show a => ({b : _} -> Show b => b -> String) -> a -> String
appShow s x = s x
myshow : Show a => a -> String
myshow = show
bar : Int -> String
bar x = appShow myshow x
bar' : Int -> String
bar' x = appShow show x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment