Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.12.0 release notes #332

Closed
davidchambers opened this issue Feb 13, 2017 · 5 comments
Closed

v0.12.0 release notes #332

davidchambers opened this issue Feb 13, 2017 · 5 comments

Comments

@davidchambers
Copy link
Member

v0.11.1...v0.12.0

Overview

This is a huge release, representing hundreds of hours of work over the course of more than eight months, spanning multiple projects. I'm thrilled to be able to share the result. Many thanks to those who contributed to this release, either by submitting pull requests or by participating in discussions on GitHub and Gitter.

Ramda

Sanctuary began life as a tiny library intended for use alongside Ramda. At the time Ramda provided several partial functions such as R.head (this is still the case today). Since Sanctuary's inception two years ago, Ramda and Sanctuary have diverged philosophically to the point that it's now reasonable for Sanctuary to duplicate much of Ramda's functionality. Until now, though, Sanctuary has lacked crucial functions such as map, ap, and chain.

Fantasy Land

Thanks in large part to sanctuary-type-classes, Sanctuary now supports version 3 of the Fantasy Land specification. There are two aspects to this:

  • the Maybe and Either types provide lawful fantasy-land/-prefixed methods; and
  • there are 20 or so new functions for interacting with Fantasy Land methods.

In the Sanctuary world, Fantasy Land methods are not intended for direct use. Until now one was expected to use R.map(f, maybe) rather than maybe.map(f). Now that Sanctuary provides a map function, the recommended expression is S.map(f, maybe). Since S.map enforces its invariants (if type checking is enabled) there's no reason for S.Maybe.prototype['fantasy-land/map'] to do so as well. As a result, methods of the Maybe and Either types no longer perform type checking.

sanctuary-def

sanctuary-js/sanctuary-def@v0.6.0...v0.9.0

Sanctuary now depends on [email protected] which is significantly more capable than the version on which Sanctuary previously depended. It now supports higher-order functions and unary (and binary) type variables. For example:

S.filter(S.I, [0, 1, 2, 3]);
// ! TypeError: Invalid value
//
//   filter :: (Applicative f, Foldable f, Monoid f) => (a -> Boolean) -> f a -> f a
//                                                            ^^^^^^^
//                                                               1
//
//   1)  0 :: Number, FiniteNumber, Integer, ValidNumber
//
//   The value at position 1 is not a member of ‘Boolean’.
//
//   See https://github.com/sanctuary-js/sanctuary-def/tree/v0.9.0#Boolean for information about the Boolean type.

Sanctuary functions now have useful string representations for those who enjoy the REPL:

> S.lift2
lift2 :: Apply f => (a -> b -> c) -> f a -> f b -> f c

> S.match
match :: NonGlobalRegExp -> String -> Maybe { groups :: Array (Maybe String), match :: String }

> S.matchAll
matchAll :: GlobalRegExp -> String -> Array { groups :: Array (Maybe String), match :: String }

Breaking changes

New exports

Contributors

@svozza
Copy link
Member

svozza commented Feb 13, 2017

Fantastic stuff! Thank you to everyone who helped get such a big release out the door.

@davidchambers
Copy link
Member Author

I just released v0.12.1 which contains @JAForbes's fix for bundlers (#334).

@davidchambers
Copy link
Member Author

I just released v0.12.2 which contains @Avaq's tweak to make S.env compatible with $.test (#354).

@fvictorio
Copy link

How is the string representation of functions in the REPL implemented?

(I'm pretty sure this is not the right place to ask this, but that feature blew my mind and I really, really want to know how to do it.)

@Avaq
Copy link
Member

Avaq commented Mar 31, 2017

How is the string representation of functions in the REPL implemented?

Hi @fvictorio, in NodeJS, you can override the inspect method of any object, including functions, to create a custom representation of your object to show when util.inspect() is called on it. The Node REPL uses util.inspec() internally to format return values of expressions.

This feature is used by sanctuary-def to attach representations derived from the type information passed to def when defining a function. Implementation can be seen here: https://github.com/sanctuary-js/sanctuary-def/blob/v0.9.0/index.js#L2342

Most functions (if not all) exported by Sanctuary were defined using sanctuary-def, in order to curry them, decorate them with type checking, and have the custom inspection value.

I'm pretty sure this is not the right place to ask this

That's alright. If you're looking for a place to ask general questions, the Gitter channel is quite active :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants