-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Is it correct to define concatAll for Magma? #1838
Comments
Outside of typeclass methods, the type signature of a function and its documentation is all that (softly) binds it. What would a semigroup constraint/dependency change? The function could be - uselessly and misleadingly, but validly - defined as follows either way: const concatAll = <A>(_M: Semigroup<A>):
(constVal: A) => (ignored: Array<A>) => A => constant
I'd tend to agree with that. I've found no use for it except tripping up beginners. |
@samhh Maybe I'm missing your point here. What is the The way I look at it is, Magma has a concept that comes with its name. By having a concrete implementation of In another words, to my opinion we cannot implement a good |
The only thing that codifies associativity is the typeclass constraint. As per above we can define alternative behaviours for |
Looking at the code for
concatAll
for Magma here, is it correct to defineconcatAll
for Magma? This is how it is implemented right now in fp-ts:The definition of Magma is only mentioning that
concat
ing 2 elements of a Set, should result in an element in that Set (Set is closed under theconcat
operation). But it doesn't necessarily an Associative operation. In that case we can have a scenario for Magma that:If that is so, then from the definition of Magma, it seems that we cannot define a
concatAll
because the order of way weconcat
elements matter and we cannot abstract over it using a function! because function at the end of the day needs to concat elements in some specific order.Do we even care for Magma s in TypeScript? I cannot think of any Magma s which are not already a Semigroup in TypeScript!
I really like to see what everyone thinks.
The text was updated successfully, but these errors were encountered: