Whenever I end up defining an `maybe(t)` typespec, I always use it for tagged tuples (`@type maybe(t) :: {:ok, t} | {:error, any}`), although I might be more specific in that `any`, although I’ve found myself defining a `result` typespec for a module far more often (because most of the functions in the module return the same or similar values).
I think what’s being described here is closer to `option(t)`, so `@type option(t) :: t | nil` (although that’s also a tagged value in Rust, but `t | nil` seems closer to the spirit of `option` than `maybe`). -a On Wed, Feb 28, 2018 at 9:43 AM, Ben Wilson <benwilson...@gmail.com> wrote: > Is nillable(String.t) less boilerplate than String.t | nil ? > > On Wednesday, February 28, 2018 at 9:12:42 AM UTC-5, Yordis Prieto wrote: >> >> I am more interested on the solution of `nil | t` I dont mind changing >> the name to `nillable(t)` or whichever other word in English. >> >> The needs come from Ecto schemas and most of the struct fields will be >> nillable(t), I thought it would be good to have something that represent >> that common use case. >> >> On Tuesday, February 27, 2018 at 4:11:39 AM UTC-8, Yordis Prieto wrote: >>> >>> Introducing `maybe(t)` it will reduce the boilerplate code for `nil | >>> something` >>> >>> It is more convenience to write it this way, at least for me. >>> >>> What are your thoughts about it? >>> >> -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/c0d589bc-951d-4b5d-afef- > d652d8a84310%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/c0d589bc-951d-4b5d-afef-d652d8a84310%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca http://www.halostatue.ca/ • http://twitter.com/halostatue -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAJ4ekQs-EVcx95hc0vUZrFuatOcG7fq11_uaV7Y4phgkZP3%3DnA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.