(module forma_2_show_color

  (data Color
    (doc "A small 3-variant enum used to exercise instance Show on a user ADT.")
    (ctor Red)
    (ctor Green)
    (ctor Blue))

  (instance
    (class prelude.Show)
    (type (con Color))
    (method show
      (body
        (lam
          (params (typed c (con Color)))
          (ret (con Str))
          (body
            (match c
              (case (pat-ctor Red)   "Red")
              (case (pat-ctor Green) "Green")
              (case (pat-ctor Blue)  "Blue")))))))

  (fn main
    (type (fn-type (params) (ret (own (con Unit))) (effects IO)))
    (params)
    (body
      (seq
        (seq
          (app print (term-ctor Color Red))
          (app print (term-ctor Color Green)))
        (app print (term-ctor Color Blue))))))
