-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sanctuary >0.15.0 compatibility and general improvements #8
Conversation
src/Reader.js
Outdated
Reader.ask = Reader (S.I); | ||
|
||
Reader.prototype.toString = Reader.prototype[$$show] = function show_() { | ||
return 'Reader(' + show (this.run) + ')'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Reader (...)
to match Sanctuary style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean add a space between Reader
and the opening parens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more specific, change it to Reader (' + show (this.run) + ')';
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call be impatient, but I just made the change I assumed you meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
00f7707
to
cc4129f
Compare
Added tests for |
I suggest bumping version to |
This should be part of an automated release process. Would you like me to submit a pull request to integrate xyz? |
While testing this on XOD codebase, I found an interesting thing about HOFs that deal with functions with 2+ arguments. We parse const {types} = resolve ($) ([]) ($.env) ('foo :: String -> (String -> Number -> Boolean) -> String');
const lists = S.zip (types) ([$.String, $.Function ([$.String, $.Number, $.Boolean]), $.String]);
assertTypePairs (lists); // passes But since const signature = 'foo :: a -> (a -> a -> Boolean) -> a';
const foo = def
(signature)
(() => 'implementation does not matter for this example');
assert.equal (foo.toString (), signature);
// + expected - actual
// -foo :: a -> ((a, a) -> Boolean) -> a
// +foo :: a -> (a -> a -> Boolean) -> a |
Forgot about how [$.Function ([a, $.Function ([b, c])]), d] instead of [$.Function ([a, b, c]), d] Shouldn't be that hard (right?) |
Yes, that would be very nice. In this case, @Gipphe, please do not bump the version |
Yes |
@evgenykochetkov Done. |
It now supports type signatures like |
src/signature.js
Outdated
const firstChild = S.pipe ([ | ||
children, | ||
S.head, | ||
unchecked.fromMaybe (undefined), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return undefined
rather than S.Nothing
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time I wrote this function, I cared more to copy the dependent-upon behavior of R.compose(R.head, children)
, which was the previous implementation. Now that tests are passing, I can safely redo it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this function will never receive an object that has an empty children
property, so we can go even simpler and do with xs => xs[0]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. You should update the type signature accordingly:
-// firstChild :: { children :: Array a } -> a
+// firstChild :: { children :: NonEmpty (Array a) } -> a
I think this is the clearest implementation:
const firstChild = r => r.children[0];
I also suggest aligning the type signature with the identifier on the subsequent line:
// firstChild :: { children :: NonEmpty (Array a) } -> a
const firstChild = r => r.children[0];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to update a lot of the type signatures I see now, upon further inspection. This little function's isn't the only one. Aligning the type signatures is a bit of a minor thing, but I am inclined to agree that it looks better that way.
0f6d17d
to
50a505b
Compare
There are a lot of |
I used it at the peak of my craziness while getting familiar with FP on practice. It is actually an over-engineering legacy. It is absolutely OK to get rid of it. |
Am still struggling with over-engineering myself, so I feel ya. |
BREAKING CHANGE: no longer works with regular multi-arity function application. Requires functions to be curried, either manually or with the help of functions like `ramda`'s `curry` and `curryN`, or `sanctuary`'s own curry helpers, `curry2`-`curry5`.
Multi-arity higher order functions are types as ```javascript [ $.Function ([ a, $.Function ([ b, c ]), ]), d ] ``` instead of ```javascript [ $.Function ([ a, b, c ]), d ] ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Summary:
sanctuary-def
must be passed tocreate
in the configuration object.babel
to version7
.chai
andmocha
.ramda
withsanctuary
and some single-function packages.ramda-fantasy
'sReader
with own implementation that isfantasy-land
compatible.eslint-config-airbnb-base
to13.1.0
, updating its peer dependencies to match.Closes #7