crocks icon indicating copy to clipboard operation
crocks copied to clipboard

[WIP] Fantasy land applicatives

Open pfgray opened this issue 7 years ago • 9 comments

For #209

Just trying to collect some code around these implementations:

applyTo Tests Law tests
Async :white_check_mark: :white_check_mark: :white_check_mark:
Const :white_check_mark: :white_check_mark: :heavy_minus_sign:
Either :white_check_mark: :white_check_mark: :white_check_mark:
IO :white_check_mark: :white_check_mark: :white_check_mark:
Identity :white_check_mark: :white_check_mark: :white_check_mark:
List :white_check_mark: :white_check_mark: :white_check_mark:
Maybe :white_check_mark: :white_check_mark: :white_check_mark:
Pair :white_check_mark: :white_check_mark: :heavy_minus_sign:
Reader :white_check_mark: :white_check_mark: :white_check_mark:
Result :white_check_mark: :white_check_mark: :white_check_mark:
State :white_check_mark: :white_check_mark: :white_check_mark:
Unit :white_check_mark: :white_check_mark: :white_check_mark:
Writer :white_check_mark: :white_check_mark: :white_check_mark:

pfgray avatar Sep 25 '18 04:09 pfgray

@pfgray when you get a chance you will wanna rebase against current master. We have a fix in there for the spec runner on node:6

evilsoft avatar Oct 07 '18 06:10 evilsoft

@evilsoft , it looks like there are 5 tests failing:

  Failed Tests: There were 5 failures
    isApplicative fantasy-land
      ✖ returns false when Applicative is passed

    isApply fantasy-land
      ✖ returns false when Apply is passed

    isChain fantasy-land
      ✖ returns false when Chain is passed

    isMonad fantasy-land
      ✖ returns false when Monad is passed

    isAlternative fantasy-land
      ✖ returns false when Alternative is passed

if I remove the addition of ap from flNames.js, then they pass.

I'm not quite sure what they're testing, or how these should behave now that we have fantasy-land/ap defined on these.

pfgray avatar Oct 10 '18 04:10 pfgray

@pfgray will look into that, In the end, all of the pointfree functions should call the fantasy land function first, then dispatch to the non-prefixed. will pull down the branch and see what is going on with dem specs.

evilsoft avatar Oct 11 '18 17:10 evilsoft

@pfgray I am not seeing those same failures locally. What environment are you seeing them in?

evilsoft avatar Oct 12 '18 19:10 evilsoft

@evilsoft, ah yes, sorry... I pushed some changes to the tests in this commit since without these changes those tests fail.

Are the isApplicative methods supposed to return false if a constructor or instance of a "fantasy-land applicative" is passed? Or is it just used to determine what is an "applicative" wrt the crocks library?

Also, would this then be considered a "breaking" change?

pfgray avatar Oct 13 '18 17:10 pfgray

Ahh. sorry I misunderstood what was going on here. Yes that will be a breaking change, and TBH updating the predicates is out of scope for this PR. it should really just handle the non-breaking changes of adding applyTo to the types and even the fantasy-land/ap.

There are a few breaking changes that will be happening around this and traversable. While those specs are valid for apply and applicative, I am worried about chain and monad and alternative. Those should have been true. Digging into those right now.

EDIT: Ohhh. nope at the present time those specs are indeed valid and it looks like we are going to have to do this in a breaking change. All of those methods depend on the type being an Apply first, or it appears along the chain (monad needs to be an chain and an applicative, and both chain and applicative must be an apply) So by adding the method fantasy-land/ap, it then reports true all the way down.

So to answer your question, yes this will be a breaking change and yes it is expected, I just did not anticipate it. So sorry about the :corn:fusion.

evilsoft avatar Oct 14 '18 03:10 evilsoft

And do not sweat the breaking change, we have a couple of them coming down the pipe (Fix to Const and Writer. @bennypowers esm changes as a big change on the List ADT).

evilsoft avatar Oct 14 '18 03:10 evilsoft

Also another thing I forgot to mention, each ADT has a VERSION variable at the top and an associated spec. This marks an API version for integration with sanctuary-js, so as the API is being updated, those versions will also need to be incremented.

evilsoft avatar Oct 14 '18 04:10 evilsoft

@evilsoft @pfgray What do we need to get this merged in? I'm happy to pickup the final touches if you guys just let me know

dalefrancis88 avatar Jul 15 '19 00:07 dalefrancis88