Here is a table of SML syntax fragments with Mythryl equivalents:
SML | Mythryl | Comment |
.sig | .api | Default signature file extension has changed. |
.sml | .pkg | Default structure file extension has changed. |
.cm | .lib | ".lib" file extension has better C intuition. |
(* A comment. *) | # A comment. | Mythryl follows scripting comment convention. |
(* A comment. *) | /* A comment. */ | Mythryl also supports C-style comments. |
true false | TRUE FALSE | Mythryl constructors are consistently upper case. |
open my_package; | include package my_package; | Better C intuition, frees open for I/O use. |
unit | Void | ’Void’ carries better C intuition. |
real | Float | ’Float’ carries better C intuition. |
NONE | NULL | ’NULL’ carries better C intuition. |
SOME x | THE x | ’THE’ avoids sounding like a quantifier. |
int option | Null_Or(Int) | Latter carries better C intuition. |
string list | List(String) | Mythryl type functions are prefix. |
’a list | List(X) | Mythryl type variables are alphabetic. |
(none) | x = ‘ls -l‘; | Mythryl supports user-redefinable Perl-flavored backtick operator. |
#\a | ’a’ | Mythryl supports C-flavored character constants. |
~2 | -2 | Mythryl uses dash for unary negation, like most languages. |
a :: b | a ! b | Mythryl uses ’!’ for list construction. |
a = (b = c) | a = (b == c) | Mythryl distinguishes equality (==) from binding (=). |
!ptr | *ptr | Per C intuition, Mythryl dereferences via prefix asterisk. |
abs a | |a| | Mythryl supports circumfix operators. |
factorial 5 | 5! | Mythryl supports postfix operators. |
not a | !a | Mythryl supports usual C negation convention. |
not a | not a | Mythryl also supports this. |
a bit_or b | a | b | Mythryl supports C inclusive-or syntax. |
a andalso b | a and b | Mythryl short-circuit ops follow Perl & kith. |
a orelse b | a or b | Ditto. |
mystructure.myfunction | mypackage::myfunction | Mythryl follows C++ convention. |
#field record | record.field | Mythryl follows C convention. |
#field record | .field record | Mythryl still supports fieldname-as-function. |
(none) | for (x=0; x<12; ++x) { ... } | Mythryl implements C-flavored (but pure-functional) for-loop. |
(none) | x where ... end; | Mythryl implements where clauses. |
format "%d\n" [ INT 12 ] | printf "%d\n" 12; | Mythryl implements Perl-flavored printf. |
let val x = 12 in x+2 end | { x = 12; x+2; } | Mythryl implements C-flavored blocks. |
case ... | case ... esac | Mythryl supplies the missing ’esac’ terminator. |
if ... | if ... fi | Mythryl supplies the missing ’fi’ terminator. |
if foo then print "Hi!\n" else () | if foo print "Hi!\n" fi | Missing else clause defaults to () in Mythryl. |
(none) | if ... elif ... else ... fi | Mythryl supports ’elif’. |
val x = if y then 2 else 3 | x = y ?? 2 :: 3; | Mythryl supports C-flavored conditional. |
handle | except | “except” clarifies the tie to exception handling. |
structure | package | “struct” means “record” to C intuition so we avoid the word. |
signature | api | “api” carries better C intuition. |
functor | generic package | “generic package” carries better C intuition. |
signature Foo = sig ... end | api Foo { ... }; | This syntax is more compact and more C-intuitive. |
structure foo = struct ... end | package foo { ... }; | Ditto. |
sig ... end | api _ { ... }; | We avoid spending a reserved word for anonymous case. |
struct ... end | package _ { ... }; | Ditto. |
my_struct :> my_sig | my_package: my_api | Mythryl gives strong sealing the compact syntax. |
my_struct : my_sig | my_package: (weak) my_api | Mythryl weak sealing syntax is clear and extensible. |
op + | (+) | Concise Haskell syntax for quoting infix ops. ("op" is not a reserved word in Mythryl.) |
infix +++ ; | infix my +++ ; | "infix" is not a reserved word in Mythryl. (Nor, e.g., "type", "in", "do" or "let".) |