Created
July 5, 2011 22:48
-
-
Save niuk/1066137 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
| interface Eq require | |
| {type T; eq} | |
| interface Eq provide | |
| type T : Type | |
| eq : (T, T) -> Bool | |
| module EqInt : Eq where | |
| type T = Int | |
| eq = builtIn_eqInt | |
| interface Cmp require | |
| module C : Eq | |
| lt : (T, T) -> Bool | |
| interface Cmp default | |
| type T = C.T | |
| type Result = | |
| $lesser $equal $greater | |
| cmp(x, y) = | |
| if C.eq(x, y) | |
| then $equal | |
| else | |
| if lt(x, y) | |
| then $lesser | |
| else $greater | |
| interface Cmp provide | |
| {type T; type Result; cmp} | |
| module CmpInt : Cmp where | |
| module C = EqInt | |
| lt = builtIn_ltInt |
Author
Haskell is my favorite language, too, although it's not suitable all the time. I work as a PHP programmer.
Have you looked at exensions like O'Haskell (or Haskell++) and Cayenne?
Author
So apparently combining ML's module system with Haskell's typeclasses yields the equivalent of Java's interfaces and classes, minus inheritance. Go to https://github.com/Nenmin/Nail/blob/master/syntax to see what I mean.
I'll have a closer look at Nail.
After getting in contact with my "old" Haskell teacher, I was reminded that O'Haskell had turned into Timber.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haskell is my favorite programming language, and I deliberately try to emulate it when designing this language. Interfaces are basically Haskell typeclasses, and classes are instances, except named and parameterized.