mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
@@ -2025,8 +2025,9 @@ Standard ML:
|
||||
aliases:
|
||||
- sml
|
||||
extensions:
|
||||
- .sml
|
||||
- .ML
|
||||
- .fun
|
||||
- .sml
|
||||
|
||||
Stata:
|
||||
type: programming
|
||||
|
||||
@@ -566,6 +566,7 @@
|
||||
".nut"
|
||||
],
|
||||
"Standard ML": [
|
||||
".ML",
|
||||
".fun",
|
||||
".sig",
|
||||
".sml"
|
||||
@@ -733,8 +734,8 @@
|
||||
".gemrc"
|
||||
]
|
||||
},
|
||||
"tokens_total": 613550,
|
||||
"languages_total": 801,
|
||||
"tokens_total": 613712,
|
||||
"languages_total": 802,
|
||||
"tokens": {
|
||||
"ABAP": {
|
||||
"*/**": 1,
|
||||
@@ -60840,67 +60841,67 @@
|
||||
"newplayer.MoveTo": 1
|
||||
},
|
||||
"Standard ML": {
|
||||
"structure": 15,
|
||||
"LazyBase": 4,
|
||||
"LAZY_BASE": 5,
|
||||
"struct": 13,
|
||||
"type": 6,
|
||||
"a": 78,
|
||||
"exception": 2,
|
||||
"Undefined": 6,
|
||||
"fun": 60,
|
||||
"delay": 6,
|
||||
"f": 46,
|
||||
"force": 18,
|
||||
"(": 840,
|
||||
")": 845,
|
||||
"val": 147,
|
||||
"undefined": 2,
|
||||
"fn": 127,
|
||||
"raise": 6,
|
||||
"end": 55,
|
||||
"LazyMemoBase": 4,
|
||||
"datatype": 29,
|
||||
"|": 226,
|
||||
"Done": 2,
|
||||
"of": 91,
|
||||
"lazy": 13,
|
||||
"unit": 7,
|
||||
"-": 20,
|
||||
"let": 44,
|
||||
"open": 9,
|
||||
"B": 2,
|
||||
"inject": 5,
|
||||
"x": 74,
|
||||
"isUndefined": 4,
|
||||
"ignore": 3,
|
||||
";": 21,
|
||||
"false": 32,
|
||||
"handle": 4,
|
||||
"true": 36,
|
||||
"toString": 4,
|
||||
"if": 51,
|
||||
"then": 51,
|
||||
"else": 51,
|
||||
"eqBy": 5,
|
||||
"p": 10,
|
||||
"y": 50,
|
||||
"eq": 3,
|
||||
"op": 2,
|
||||
"compare": 8,
|
||||
"Ops": 3,
|
||||
"map": 3,
|
||||
"Lazy": 2,
|
||||
"LazyFn": 4,
|
||||
"LazyMemo": 2,
|
||||
"signature": 2,
|
||||
"LAZY_BASE": 3,
|
||||
"sig": 2,
|
||||
"type": 5,
|
||||
"a": 74,
|
||||
"lazy": 12,
|
||||
"-": 19,
|
||||
")": 826,
|
||||
"end": 52,
|
||||
"LAZY": 1,
|
||||
"bool": 9,
|
||||
"val": 143,
|
||||
"inject": 3,
|
||||
"toString": 3,
|
||||
"(": 822,
|
||||
"string": 14,
|
||||
"eq": 2,
|
||||
"*": 9,
|
||||
"eqBy": 3,
|
||||
"compare": 7,
|
||||
"order": 2,
|
||||
"map": 2,
|
||||
"b": 58,
|
||||
"structure": 10,
|
||||
"Ops": 2,
|
||||
"LazyBase": 2,
|
||||
"struct": 9,
|
||||
"exception": 1,
|
||||
"Undefined": 3,
|
||||
"fun": 51,
|
||||
"delay": 3,
|
||||
"f": 37,
|
||||
"force": 9,
|
||||
"undefined": 1,
|
||||
"fn": 124,
|
||||
"raise": 5,
|
||||
"LazyMemoBase": 2,
|
||||
"datatype": 28,
|
||||
"|": 225,
|
||||
"Done": 1,
|
||||
"of": 90,
|
||||
"unit": 6,
|
||||
"let": 43,
|
||||
"open": 8,
|
||||
"B": 1,
|
||||
"x": 59,
|
||||
"isUndefined": 2,
|
||||
"ignore": 2,
|
||||
";": 20,
|
||||
"false": 31,
|
||||
"handle": 3,
|
||||
"true": 35,
|
||||
"if": 50,
|
||||
"then": 50,
|
||||
"else": 50,
|
||||
"p": 6,
|
||||
"y": 44,
|
||||
"op": 1,
|
||||
"Lazy": 1,
|
||||
"LazyFn": 2,
|
||||
"LazyMemo": 1,
|
||||
"functor": 2,
|
||||
"Main": 1,
|
||||
"S": 2,
|
||||
@@ -66955,7 +66956,7 @@
|
||||
"SourcePawn": 2080,
|
||||
"SQL": 1485,
|
||||
"Squirrel": 130,
|
||||
"Standard ML": 6405,
|
||||
"Standard ML": 6567,
|
||||
"Stata": 3133,
|
||||
"Stylus": 76,
|
||||
"SuperCollider": 133,
|
||||
@@ -67143,7 +67144,7 @@
|
||||
"SourcePawn": 1,
|
||||
"SQL": 5,
|
||||
"Squirrel": 1,
|
||||
"Standard ML": 4,
|
||||
"Standard ML": 5,
|
||||
"Stata": 7,
|
||||
"Stylus": 1,
|
||||
"SuperCollider": 1,
|
||||
@@ -67172,5 +67173,5 @@
|
||||
"Zephir": 2,
|
||||
"Zimpl": 1
|
||||
},
|
||||
"md5": "900536b7898278f2fd14fa3a8badf215"
|
||||
"md5": "4754c31a712c5e22354851fd14d4d4fa"
|
||||
}
|
||||
75
samples/Standard ML/Foo.ML
Normal file
75
samples/Standard ML/Foo.ML
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
structure LazyBase:> LAZY_BASE =
|
||||
struct
|
||||
type 'a lazy = unit -> 'a
|
||||
|
||||
exception Undefined
|
||||
|
||||
fun delay f = f
|
||||
|
||||
fun force f = f()
|
||||
|
||||
val undefined = fn () => raise Undefined
|
||||
end
|
||||
|
||||
structure LazyMemoBase:> LAZY_BASE =
|
||||
struct
|
||||
|
||||
datatype 'a susp = NotYet of unit -> 'a
|
||||
| Done of 'a
|
||||
|
||||
type 'a lazy = unit -> 'a susp ref
|
||||
|
||||
exception Undefined
|
||||
|
||||
fun delay f =
|
||||
let
|
||||
val r = ref (NotYet f)
|
||||
in
|
||||
fn () => r
|
||||
end
|
||||
|
||||
fun force f =
|
||||
case f() of
|
||||
ref (Done x) => x
|
||||
| r as ref (NotYet f') =>
|
||||
let
|
||||
val a = f'()
|
||||
in
|
||||
r := Done a
|
||||
; a
|
||||
end
|
||||
|
||||
val undefined = fn () => raise Undefined
|
||||
end
|
||||
|
||||
functor LazyFn(B: LAZY_BASE): LAZY' =
|
||||
struct
|
||||
|
||||
open B
|
||||
|
||||
fun inject x = delay (fn () => x)
|
||||
|
||||
fun isUndefined x =
|
||||
(ignore (force x)
|
||||
; false)
|
||||
handle Undefined => true
|
||||
|
||||
fun toString f x = if isUndefined x then "_|_" else f (force x)
|
||||
|
||||
fun eqBy p (x,y) = p(force x,force y)
|
||||
fun eq (x,y) = eqBy op= (x,y)
|
||||
fun compare p (x,y) = p(force x,force y)
|
||||
|
||||
structure Ops =
|
||||
struct
|
||||
val ! = force
|
||||
val ? = inject
|
||||
end
|
||||
|
||||
fun map f x = delay (fn () => f (force x))
|
||||
|
||||
end
|
||||
|
||||
structure Lazy' = LazyFn(LazyBase)
|
||||
structure LazyMemo = LazyFn(LazyMemoBase)
|
||||
Reference in New Issue
Block a user