I forgot that the new trend should be using glot.io :)
https://glot.io/snippets/eex5kpwvqd
On Saturday, May 21, 2016 at 8:46:53 AM UTC-4, gmhwxi wrote:
>
> Sometimes, one needs to add a state type annotation
> to an if-then-else expression in ATS. Here is a simple example:
>
> //
> fun
> foo{i:nat}
> (x: int(i), y: int(i+1)): void = ()
> //
> (* ****** ****** *)
>
> implement
> main0 () = () where
> {
> //
> var x: int
> var y: int
> //
> val i = (1: intGte(0))
> //
> val () = (
> //
> if: [i:nat]
> (
> x: int(i), y: int(i+1)
> ) => (i >= 1)
> then (x := i; y := x+1)
> else (x := 10; y := 11)
> //
> ) : void // end of [val]
> //
> val () = foo(x, y)
> //
> val () = println! ("x = ", x, "and y = ", y)
> //
> } (* end of [main0] *)
>
>
> Without the annotation, foo(x, y) cannot pass typechecking in ATS.
>
> You can also use state type annotation with case-expressions as well.
>
> Here are some examples:
>
>
> https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/TESTATS/ifhead.dats
>
> https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/TESTATS/casehead.dats
>
>
--
You received this message because you are subscribed to the Google Groups
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/b79b527e-7a6a-424f-9169-dcc024b36041%40googlegroups.com.