-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop support for "primitive" dispatching
A while ago, I added sanctuary-type-classes as a dependency to Fluture, primarily to gain its fantastic toString implementation. As a side-effect, Fluture got to use its dispatcher implementations for ap, map, bimap, chain, and alt. Now that sanctuary-show has the toString logic, there is little to gain from including the entirety of sanctuary-type-classes for dispatching to FL methods. The gains were: - Some of its logic did not have to be reimplemented. Though as shown by this diff, not that much. - Fluture dispatchers could be used on primitive types (like Fluture.map(f, [1, 2, 3])). I believe this functionality was rarely, if ever, used. Furthermore, TypeScript users were unable to use it out of the box because of the limitations of TypeScript. The losses however: - A fairly big increase of the bundle size, which as of recent I have been working to reduce. - A minor hit on the performance of these dispatchers. - The management cost of an additional dependency. - Breaking changes to sanctuary-type-classes primitive dispatching would propagate to a breaking change in Fluture which was confusing to users (see https://git.io/fAGsJ#issuecomment-355616168 for example).
- Loading branch information
Showing
10 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import Z from 'sanctuary-type-classes'; | ||
import {isAlt} from '../internal/predicates'; | ||
import {FL} from '../internal/const'; | ||
import {partial1} from '../internal/utils'; | ||
import {throwInvalidArgument} from '../internal/throw'; | ||
|
||
function alt$left(left, right){ | ||
if(!Z.Alt.test(right)) throwInvalidArgument('alt', 1, 'be an Alt', right); | ||
return Z.alt(left, right); | ||
if(!isAlt(right)) throwInvalidArgument('alt', 1, 'be an Alt', right); | ||
return left[FL.alt](right); | ||
} | ||
|
||
export function alt(left, right){ | ||
if(!Z.Alt.test(left)) throwInvalidArgument('alt', 0, 'be an Alt', left); | ||
if(!isAlt(left)) throwInvalidArgument('alt', 0, 'be an Alt', left); | ||
if(arguments.length === 1) return partial1(alt$left, left); | ||
return alt$left(left, right); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import Z from 'sanctuary-type-classes'; | ||
import {isApply} from '../internal/predicates'; | ||
import {FL} from '../internal/const'; | ||
import {partial1} from '../internal/utils'; | ||
import {throwInvalidArgument} from '../internal/throw'; | ||
|
||
function ap$mval(mval, mfunc){ | ||
if(!Z.Apply.test(mfunc)) throwInvalidArgument('Future.ap', 1, 'be an Apply', mfunc); | ||
return Z.ap(mval, mfunc); | ||
if(!isApply(mfunc)) throwInvalidArgument('Future.ap', 1, 'be an Apply', mfunc); | ||
return mfunc[FL.ap](mval); | ||
} | ||
|
||
export function ap(mval, mfunc){ | ||
if(!Z.Apply.test(mval)) throwInvalidArgument('Future.ap', 0, 'be an Apply', mval); | ||
if(!isApply(mval)) throwInvalidArgument('Future.ap', 0, 'be an Apply', mval); | ||
if(arguments.length === 1) return partial1(ap$mval, mval); | ||
return ap$mval(mval, mfunc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters