Comments (4)
Oops, sorry, I meant to undo this change actually. I was intending to copy everything exactly as it is so as not to introduce new problems, and then we could discuss changes like this one.
Feel free to change it back, you should have commit access to all these library repos.
By the sounds of it we should just wait for default implementations before moving zipWithA. I kind of like the idea of having a zipWith
in traversable, as then it could take a t a
rather than [a]
... but Traversable
doesn't have a specific order if I remember rightly?
from purescript-control.
It seems like Data.Traversable
would be a good place to put zipWithA
until we think about implementing defaults, no?
from purescript-control.
Feel free to change it back, you should have commit access to all these library repos.
Nice!
Thinking about it, zipWith
is really just a special case of <*>
for Array
(maybe others?). We should be able to implement an instance for Array
that favors zipping, not combinations, so it shouldn't even be needed except to save transforming into and out of the other instance.
newtype ZipArray a = ZipArray [a]
instance Functor ZipArray where
fmap f (ZipArray xs) = ZipArray (fmap f xs)
instance Applicative ZipArray where
pure = ZipArray . repeat
(ZipArray fs) <*> (ZipArray xs) = ZipArray (go fs xs)
where
go (g:gs) (y:ys) = g y : go gs ys
go _ _ = []
Then we could do things like:
(+1) <$> ZipArray [1,2,3]
and we have the same semantics as normal Array
Or use the Applicative
to do
(+) <$> ZipArray [1,2,3] <*> pure 1
And have it act like zipWith
. Of course this generalizes to arbitrary arity functions like all Applicative
s. In other words,
zipWith f xs ys = fromZipArray (f <$> toZipArray xs <*> toZipArray ys)
Or something.
So it should ultimately stay in Control.Applicative
or be part of the Data.Array
family (which seems more intuitive) once things are all done.
from purescript-control.
Closing this as I guess we must have figured it out at some point in the last year 😉
from purescript-control.
Related Issues (20)
- Add (<$$>) HOT 2
- $> breaks operator symmetry HOT 28
- Include a class for `hoist`? HOT 10
- Unknown module Data.Functor Control.Category, Data.Unit, Prelude HOT 4
- Annihilation law of alternative has incorrect order? HOT 1
- Add MonadOr? HOT 2
- laws for Lazy HOT 2
- provide filter for Alternative and Monad? HOT 5
- Use fundeps for an intermediate representation in `defer` HOT 8
- Definition of `fix` lacks sharing HOT 1
- MonadZero and MonadPlus seem redundant? HOT 10
- purescript-control#^3.0.0 vs purescript-control#^4.0.0 HOT 1
- class Lazy1 f where defer1 :: forall a. (Unit -> f a) -> f a HOT 10
- Lazy instance for `Effect`
- Deprecate MonadZero HOT 21
- The distributivity law for Alternative rules out effectful instances HOT 28
- Remove deprecated MonadZero instance (v0.15.0 PS)
- Update class hierarchy to remove mention of MonadZero
- Consider updating misleading Alt documentation HOT 2
- Proposal: Make <|> right associative HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from purescript-control.