3 ms·
I'm not sure whether my issue with ATS is the style of the author or its type system, although I suspect the former. ATS is based on ML (the author started wit
by mcguire 12y ago
I'm not sure whether my issue with ATS is the style of the author or its type system, although I suspect the former.
ATS is based on ML (the author started with Dependent ML), but the code has a very imperative feel, leading to statements like "let () = expr() in ..." and "let x = ... in ()".
The stuff at http://www.ats-lang.org/Examples.html http://www.ats-lang.org/Examples.html is just hideous, by the way.
- codygman 12y agoI agree with you, though I think it is because of the authors style. Check out some of Chris Done's ats code examples in a more appealing style: https://gist.github.com/chrisdone/c23251e8b975dc805876 https://gist.github.com/chrisdone/c23251e8b975dc805876
- codygman 12y agoHere's just a small translation of the ats examples[0] page. ----------------- Copying File ---------------- Authors version: fun fcopy ( inp: FILEref , out: FILEref ) : void = let val c = fileref_getc (inp) in if c >= 0 then let val () = fileref_putc (out, c) in fcopy (inp, out) end // end of [if] end (* end of [fcopy] *) ----------------- Naieve Fibonacci ---------------- My version: fun fcopy ( inp: FILEref, out: FILEref ) : void = let val c = fileref_getc (inp) in if c >= 0 then let val () = fileref_putc (out, c) in fcopy (inp, out) end end Authors version: fun fib ( n: int ) : int = if n >= 2 then fib (n-2) + fib (n-1) else n My Version (not sure if valid!): fun fib ( n: int ) : int = if n >= 2 then fib (n-2) + fib (n-1) else n ----------------- Fast Fibonacci ---------------- Authors Version: fun fibc ( n: int ) : int = let fun loop (n: int, f0: int, f1: int) = if n > 0 then loop (n-1, f1, f0+f1) else f0 // end of [loop] in loop (n, 0, 1) end // end of [fibc] My Version: fun fibc ( n: int ) : int = let fun loop (n: int, f0: int, f1: int) = if n > 0 then loop (n-1, f1, f0+f1) else f0 in loop (n, 0, 1) end 0: http://www.ats-lang.org/Examples.html http://www.ats-lang.org/Examples.html