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.

Can someone explain me how I should understand Semigroup?

See original GitHub issue
fantasy-land/concat :: Semigroup a => a ~> a -> a

Since there are so many as, it’s quite confusing though I’ve read the documentation. Can someone provide me an actual example please?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
CrossEyecommented, Sep 22, 2020

@jujoba: There’s a typo in the second bullet.

  • a ~> means: The following function is a method of an a (chain is a method of an instance that has a Semigroup)

should read

  • a ~> means: The following function is a method of an a (concat is a method of an instance that has a Semigroup)
1reaction
davidchamberscommented, Jul 2, 2020

Here are some examples, using S.concat:

> S.concat ('abc') ('def')
'abcdef'

> S.concat ([1, 2, 3]) ([4, 5, 6])
[1, 2, 3, 4, 5, 6]

> S.concat ({x: 1, y: 2}) ({y: 3, z: 4})
{x: 1, y: 3, z: 4}

> S.concat (S.Just ([1, 2, 3])) (S.Just ([4, 5, 6]))
Just ([1, 2, 3, 4, 5, 6])

> S.concat (Sum (18)) (Sum (24))
Sum (42)

S.concat is easier to understand than the underlying fantasy-land/concat methods for several reasons:

  • its type signature does not contain a squiggly arrow (~>);
  • it does not reference fantasy-land/concat explicitly; and
  • it works for some built-in types such as String, even though String.prototype['fantasy-land/concat'] is undefined.

Here is an example of invoking a fantasy-land/concat method directly:

> S.Just ('abc') ['fantasy-land/concat'] (S.Just ('def'))
Just ('abcdef')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Discrete Mathematics SemiGroup - Javatpoint
SemiGroup. Let us consider, an algebraic system (A, *), where * is a binary operation on A. Then, the system (A, *) is...
Read more >
Why semigroups could be important? - MathOverflow
C0-semigroups are fundamental in PDEs (in probability too as mentioned by Steinhurst). The reason is that a lot of evolution PDEs (basically all ......
Read more >
Chapter I: Groups 1 Semigroups and Monoids
A semigroup (S,∗) is called a monoid if it has an identity element. 1.2 Examples (a) Addition (resp. multiplication) on N0 = {0,1,2,...}...
Read more >
Semigroup - Wikipedia
Consequently, monoids are studied in the theory of semigroups rather than in group theory. Semigroups should not be confused with quasigroups, which are...
Read more >
Why are groups more important than semigroups?
I know that groups are associated with symmetries, or with automorphisms of structures. Cayley's Theorem tells me that every group can be seen ......
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