question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What’s the appropriate type of Z.of? There appear to be two options:

of :: Applicative f => (f a, b) -> f b
of :: Applicative f => ({ fantasy-land/of :: a -> f a }, b) -> f b

The advantage of the first option is that given Applicative f => f a we can find the of function in either of the valid locations:

typeof x['fantasy-land/of'] === 'function' ? x['fantasy-land/of']
                                           : x.constructor['fantasy-land/of']

With the second option the caller would need to do this work:

Z.of(typeof x['fantasy-land/of'] === 'function' ? x : x.constructor, 42)

We shouldn’t optimize for the case in which we already have a value of the type, though. After all, the purpose of of is to allow us to create values of the type so we shouldn’t need to create a value of the type in order to create a value of the type! Thus the second option seems more sensible. Do others agree?

Whatever we decide here should determine the type of Z.chainRec as well. Z.empty is a different matter because an empty method is strictly more powerful than an empty function (though this will no longer apply if and when fantasyland/fantasy-land#164 is merged).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davidchamberscommented, Oct 2, 2016

I’ve updated #2. Please have a look at the change and let me know your thoughts. 😃

1reaction
davidchamberscommented, Sep 25, 2016

That would be very nice, @safareli, but the FL spec doesn’t require Type values such as S.Maybe to exist. Everything in the spec is written from the perspective of a member of a type. So we need to accept a type dictionary, but we don’t know where such a dictionary will come from. It could be Foo itself, or Foo.prototype, or Foo.of(42), or new Foo(42).

I think the spec should require a Type value to be defined. of, empty, and chainRec should be defined on the Type value (and nowhere else), and each member of the type should have a fantasy-land/type property which points to the Type value. Then a function such as Z.of could simply require a Type value as an argument.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Z - Wikipedia
Z (or z) is the 26th and last letter of the Latin alphabet, used in the modern English ... Writing cursive forms of...
Read more >
Z-table (Right of Curve or Left) - Statistics How To
The z-table is short for the “Standard Normal z-table”. The Standard Normal model is used in hypothesis testing, including tests on proportions and...
Read more >
Z-Score Table | Formula, Distribution Table, Chart & Example
The z score table helps to know the percentage of values below (to the left) a z-score in a standard normal distribution. What...
Read more >
Z TABLE - Z TABLE
A Z Score is measured in terms of standard deviations from the mean. Which means that if Z Score = 1 then that...
Read more >
4. The z-Score
There are three types of area calculations that you will be performing, each requiring slightly different work: For areas to the left of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found