How to implement Either_vt?

Check out ATSLIB/prelude/option_vt http://ats-lang.sourceforge.net/LIBRARY/prelude/SATS/DOCUGEN/HTML/option_vt.html for how option_vt is implemented, it is the dataviewtype equivalent of Haskell’s Maybe. either_vt would take two type parameters, and instead of Some and None it would have Left and Right constructors.> On Feb 22, 2015, at 6:12 AM, Kiwamu Okabe kiw...@debian.or.jp wrote:

Hi all,

Haskell language has Either type that represents values with two possibilities:
a value of type Either a b is either Left a or Right b.

Prelude

How to implement Either_vt on ATS2?

Best regards,

Kiwamu Okabe at METASEPI DESIGN


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 ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAEvX6d%3DS49_RCX%2Bz-Ce3_qXXYR-89TxaQwRM%2BW0XnMb9Mc%3D6pQ%40mail.gmail.com.

In ATS, there are either_p (por) and either_v (vor) for props and views,
respectively.

datavtype
either_vt
(
a1:vt@ype+
, a2:vt@ype+
, bool (left/right:true/false)
) =
| inj_left(a1, a2, true) of a1
| inj_right(a1, a2, false) of a2

vtypedef
Either_vt(a1:vt@ype, a2:vt@ype) = [b:bool] either_vt(a1, a2, b)

Surprisingly, the need for either_vt is very rare in practice. So it is not
included in ATS at this moment.On Sunday, February 22, 2015 at 6:13:14 AM UTC-5, Kiwamu Okabe wrote:

Hi all,

Haskell language has Either type that represents values with two
possibilities:
a value of type Either a b is either Left a or Right b.

Prelude

How to implement Either_vt on ATS2?

Best regards,

Kiwamu Okabe at METASEPI DESIGN