FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Functional Programming Refresher
NewsProgramming Languages

Functional Programming Refresher

via Dev.toSimon Horlick4h ago

A Magma is a set with a (closed) binary operation. A Semigroup is a magma where the operation is associative. class Semigroup a where ( <> ) :: a -> a -> a -- ^ read as "append" Must satisfy: ( x <> y ) <> z == x <> ( y <> z ) -- associativity Example: [ 1 , 2 ] <> [ 3 , 4 ] <> [ 5 ] == [ 1 , 2 , 3 , 4 , 5 ] A Monoid is a semigroup with an identity element. class Semigroup a => Monoid a where mempty :: a -- ^ identity element of <> Must satisfy: mempty <> x == x -- left identity x <> mempty == x -- right identity ( x <> y ) <> z == x <> ( y <> z ) -- associativity (from Semigroup) Note: mappend is a historical name for <> and is now deprecated. Example: mempty <> [ 1 , 2 ] == [ 1 , 2 ] singleton 1 <> mempty == singleton 1 A Group is a monoid where every element has an inverse. class Monoid a => Group a where invert :: a -> a -- ^ inverse of <> Must satisfy: x <> invert x == mempty == invert x <> x A Functor represents a type that can be mapped over. class Functor f where fmap :: ( a ->

Continue reading on Dev.to

Opens in a new tab

Read Full Article
0 views

Related Articles

Oppo’s nearly creaseless foldable isn’t launching in Europe after all
News

Oppo’s nearly creaseless foldable isn’t launching in Europe after all

The Verge • 16m ago

Amazon adds 1-hour and 3-hour delivery options in the US
News

Amazon adds 1-hour and 3-hour delivery options in the US

TechCrunch • 42m ago

News

Seeing the Web

Lobsters • 44m ago

Best early Amazon Spring Sale TV deals 2026: Save big on Samsung, TCL, and more
News

Best early Amazon Spring Sale TV deals 2026: Save big on Samsung, TCL, and more

ZDNet • 1h ago

Age-Gating Isn’t About Kids, It’s About Control
News

Age-Gating Isn’t About Kids, It’s About Control

Lobsters • 1h ago

Discover More Articles