-
-
Save niuk/1066137 to your computer and use it in GitHub Desktop.
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 |
A hypothetical language that currently exists only in my head.
Okey. I love that (i.e. people having ideas about languages)!
I think I have come up with an improved formulation of the same concepts.
Have you taken ideas from Haskell? Your interfaces Eq and Cmp are very similar to Haskell's classes Eq and Ord.
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.
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?
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.
What language?