Last active
October 26, 2017 21:35
-
-
Save david-christiansen/1e6e17ec7637cde6d074 to your computer and use it in GitHub Desktop.
Generating a "Show" instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MkShow | |
import Language.Reflection.Elab | |
mkShow : (a : Type) -> (a -> String) -> Show a | |
mkShow = %runElab (fill (Var (SN (InstanceCtorN `{Show}))) *> solve) | |
shower : Show Float | |
shower = mkShow _ (const "oops") | |
normalShow : show 3.2 = "3.2" | |
normalShow = Refl | |
myShow : show @{shower} 3.2 = "oops" | |
myShow = Refl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment