Source

pygments-main / tests / examplefiles / example.sml

Full commit
(*(*(*(*(* This file is all pretty strange Standard ML *)*)*)*) (**)*)
(* Robert J. Simmons *)

signature BA_Z = sig 
   val s: int
end 

structure b______ = struct (* What (* A * strange * name *) for ) a ( struct *)

val !%&$#+-/:<=>?@\~`^|* = 3

type struct' = int list
and 'a sig' = 'a list
and ('a, 'b) end' = 'b option * 'a list

structure baz = struct
  structure Bar = struct 
    val foo = !%&$#+-/:<=>?@\~`^|*
  end  
end

infixr +!+ 
fun (a +!+ b) = (op +) (a, b)

open baz

val$$$ = fn x => fn y => fn z => fn w => w
val (foo, ++, bar, ||) = (4, baz.Bar.foo, !%&$#+-/:<=>?@\~`^|*, Bar.foo)
val _ = $$$foo++bar||

val val'ue : ' list = []
val struct3 : (' -> ') = fn x => x
val end_struct_' : ('a -> 'a) = fn x => x
val x : (''a -> ''a) = fn x => x
val x : ('''' -> '''') = fn x => x
val x : unit = print "Weird, huh?\n"
val w = {x=1,y=2,##= =3,4=3}
val {##=, x, 4=a,...} = w
val z = #4 w
val z = # ##= w

fun f x y 0 = 4
  | f x y z = 4 

exception Foo of int
datatype ('0, 'b, '_, ') f'o'o = Bar | baZ12' | dsfa_fad | #@$ | Bug
and (', ''', '''', ''''') bar = 
   Bee of unit
 | Ben of (', ''', '''', ''''') f'o'o * string * int 
 | X of ''' list

fun q x = raise Foo x
and h x = raise Foo (~x)

val x = 4
and y = 5

fun q 0 = 4
  | q 1 = (case 1 of 1 => 2 | 3 => 4 | x => y)
  | q y = case y of 1 => 2 | 3 => 4 | x => y

val x = ref true
fun q 0 = 4
  | q 1 = if false then case 1 of 1 => 2 | 3 => 4 | x => y else 19
  | q 2 = (while !x handle Match => !x | Fail _ => !x do () ; 2)
  | q x = (raise Match) handle Domain => 9 | Match => 3

fun p 0 = 12
  | p 1 = 8
  | p 2 = r false
  | p x = r true
and r true = 19
  | r false = 12

val _ = 123
val _ = 0001
val _ = ~123
val _ = ~0001
val _ = 0w12412
val _ = 0w12412
val _ = 0xfA0
val _ = ~0xfA0
val _ = 0wxfA0
val _ = 1.4
val _ = ~1.4
val _ = 1e~2
val _ = 1E~2
val _ = 1e2
val _ = 1E2
val _ = 1.4e~2
val _ = 1.4E~2
val _ = 1.4e2
val _ = 1.4E2

val c = #"\000"
val st = "foo \
 	 \ bar" ^ "baz \        
  	 \ and \ 
   	 \ such\n"

val () = print st

val _ = foo::bar::4::[++]

end