Created
July 6, 2015 06:45
-
-
Save ncannasse/e235f64d2fbcac399abb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| enum Error<T> { | |
| Code( i : Int ) : Error<Int>; | |
| Message( s : String ) : Error<String>; | |
| } | |
| function getError<T>( e : Error<T> ) : T { | |
| switch( e ) { | |
| case Code(c): return c; | |
| case Message(s): return s; | |
| } | |
| } | |
| $type(getError(Code(55))); // Int | |
| $type(getError(Message("something bad happenned"))); // String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment