//
//
// An example involving array creation and array subscription
//
//

staload _(*anonymous*) = "prelude/DATS/array0.dats"

datatype weekday =
  | Monday
  | Tuesday
  | Wednesday
  | Thursday
  | Friday

val weekdays: array0 (string)
  = array0_make_arrsz {string} $arrsz {string} (
  "Monday"
, "Tuesday"
, "Wednesday"
, "Thursday"
, "Friday"
)

fn int_of_weekday (day: weekday): int =
  case+ day of
  | Monday () => 1
  | Tuesday () => 2
  | Wednesday () => 3
  | Thursday () => 4
  | Friday () => 5

fn name_of_weekday (day: weekday): string
  = weekdays[int_of_weekday day - 1]

fn print_weekday (day: weekday): void = print (name_of_weekday day)
overload print with print_weekday

implement main () = begin
  print (Monday) ;
  print ", "; print (Tuesday) ;
  print ", "; print (Wednesday) ;
  print ", "; print (Thursday) ;
  print ", "; print (Friday) ;
  print_newline ()
end // end of [main]

(* ****** ****** *)

(* end of [weekdays-2008-09-09.dats] *)