From h@wickh@m @ending from gm@il@com  Fri Aug 10 00:56:32 2018
From: h@wickh@m @ending from gm@il@com (Hadley Wickham)
Date: Thu, 9 Aug 2018 17:56:32 -0500
Subject: [Rd] vctrs: a type system for the tidyverse
In-Reply-To: <A260BC05-0755-4911-98B3-74071569A9F4@icloud.com>
References: <CABdHhvFARmiExcEk=NUjfPcRtYnoF4pAA5WTws6r1C+X76zHEw@mail.gmail.com>
 <CAMFmJsn_wNxuV2SQqUiZroJYV+rHRKdADi8Fjg8fRjJr0RGuwQ@mail.gmail.com>
 <CABdHhvEAV-bhprxVMHF_R8vKdN3VEriV86kGNNU02RiK=+m4dQ@mail.gmail.com>
 <CABdHhvHw+_sFcD3H92KQhvurxC8eAyR2A0frZUk7pBcOaVB2Hw@mail.gmail.com>
 <23403.4648.841262.201573@stat.math.ethz.ch>
 <CABdHhvH53=0b7Hg=9dAPx9zUTn4YSYR0=JoDzWMRMjkMpmXbBQ@mail.gmail.com>
 <CABdHhvGucJKbaFmB1gk3i0vgen9OPQ7Wb=nQKm7aOoBFbC0sqA@mail.gmail.com>
 <A260BC05-0755-4911-98B3-74071569A9F4@icloud.com>
Message-ID: <CABdHhvHNqWFDamNQU1ZC_Z022LdE0qBzz4swYGkMV1eFi-2hHA@mail.gmail.com>

On Thu, Aug 9, 2018 at 4:26 PM jan Vitek <vitekj at icloud.com> wrote:
>
> > I'm now confident that I
> > can avoid using "type" by itself, and instead always use it in a
> > compound phrase (like type system) to avoid confusion. That leaves the
> > `.type` argument to many vctrs functions. I'm considering change it to
> > .prototype, because what you actually give it is a zero-length vector
> > of the class you want, i.e. a prototype of the desired output. What do
> > you think of prototype as a name?
>
>
> The term ?type system? in computer science is used in very different ways.
> What the note describes is not a type system, but rather a set of
> coercions used by a small number of functions in one package.
>
> Typically it refers to a set of rules (either statically enforced
> by the compiler or dynamically enforced by the runtime) that ensure
> that some particular category of errors can be caught by the
> language.
>
> There is none of that here.

I think there's a bit of that flavour here:

vec_c(factor("a"), Sys.Date())
#> Error: No common type for factor and date

This isn't a type system imposed by the language, but I don't think
that's a reason not to call it a type system.

That said, I agree that calling it a type system is currently
overselling it, and I have made your proposed change to the README
(and added a very-long term goal of making a type system that could be
applied using (e.g.) annotations).

> "The short-term goal of vctrs is to develop a type system for vectors which will help reason about functions that combine different types of input (e.g. c(), ifelse(), rbind()). The vctrs type system encompasses base vectors (e.g. logical, numeric, character, list), S3 vectors (e.g. factor, ordered, Date, POSIXct), and data frames; and can be extended to deal with S3 vectors defined in other packages, as described in vignette("extending-vctrs?).?
>
> ==>
>
> The short-term goal of vctrs is to specify the behavior of functions that combine different types of vectors (e.g. c(), ifelse(), rbind()). The specification encompasses base vectors (e.g. logical, numeric, character, list), S3 vectors (e.g. factor, ordered, Date, POSIXct), and data frames; and can be extended to deal with S3 vectors defined in other packages, as described in vignette("extending-vctrs?).

Thanks for the nice wording!

Hadley


-- 
http://hadley.nz



[Rd] vctrs: a type system for the tidyverse
Hadley Wickham