Haskell Cheat Sheet

broken image


A cheatsheet to regexes in Haskell April 11, 2019 « Previous post Next post » UPDATE: This cheatsheet is now part of the documentation for regex-tdfa! While Haskell is great for writing parsers, sometimes the simplest solution is just to do some text. Haskell Cheat Sheet This cheat sheet attempts to lay out the fundamen-tal elements of the Haskell language and libraries. It should serve as a reference to both those learn-ing Haskell and those who are familiar with it, but maybe can't remember all the varieties of syntax and functionality. It is presented as both an executable Haskell file. As shown earlier, Haskell provides a the deriving mechanism for making it easier to define instances of typeclasses, such as Show, Read, Eq, Ord, Enum. Constructor names are printed and read as written as written in the datadeclaration, two values are. Haskell CheatSheet Written and maintained by Justin Bailey. The cheat sheet is a PDF included in the source distribution. If you installed this package through cabal install, run 'cheatsheet.exe' to find where the PDF was installed.

The below is a tiny fraction of what is available online; for more, start at haskell.org.

Cheat Sheet

Editor Plugins

Books

  • Real World Haskell by Bryan O' Sullivan, John Goerzen, and Don Stewart

  • The Haskell School of Expression by Paul Hudak

  • Programming in Haskell by Graham Hutton

  • Learn You a Haskell by Miran Lipovača

Tutorials

  • Monad Tutorial by Graham Hutton

Fancy Types and Verification

Courses

  • Dartmouth Problem Solving with Computer Science
  • UPenn Advanced Programming
  • Stanford Programming Languages
  • Princeton Programming Languages
Sheet

Miscellaneous

  • API Search Engines: HoogleHayoo

  • Haskell modes: VimEmacs

Sheet
Haskell Cheat Sheet

Cheat Sheet Pdf

Monad Examples

Keywords
  • List
  • Maybe/Optional
  • Either
  • Try (Scala specialized Either that catches exceptions)
  • Future
  • Observable/Signal

Async

OneMany
SynchronousT/Try[T]Iterable[T]
AsynchronousFuture[T]Observable[T]
Cheat sheet pdf

Miscellaneous

  • API Search Engines: HoogleHayoo

  • Haskell modes: VimEmacs

Cheat Sheet Pdf

Monad Examples

  • List
  • Maybe/Optional
  • Either
  • Try (Scala specialized Either that catches exceptions)
  • Future
  • Observable/Signal

Async

OneMany
SynchronousT/Try[T]Iterable[T]
AsynchronousFuture[T]Observable[T]

Haskell

data type

Haskell nameHaskell defEquivalent in Java or similar
type classclass SmthgInterface/Protocol
type constructordata Smthg aGeneric
concrete typeSmthg Int
data Smthg
Parametrized Generic
type synonymtypetypealias
data typedata Smthg paramClass
instance of type classinstance (TypeClass) type
data deriving (TypeClass)
implements

Concepts

Markdown Cheatsheet Pdf

NameHaskelltypedesciption
Functorfmapa->b -> f a -> f bmap (infix synonym: <$>)
Applicative(Functor)purea -> f aid/constructor, lift a value
<*>f (a -> b) -> f a -> f bsequential application, apply a functored map
Monoidmemptyaid
mappenda -> a -> acombine 2
mconcat[a] -> afold
Monadreturna -> m apure
>>=m a -> (a -> m b) -> m bbind, chain, flatmap
>>m a -> m b -> m bdiscard first

Instances of 'Monad' should satisfy the following laws:

Haskell Syntax

Instances of both 'Monad' and 'Functor' should additionally satisfy the law:





broken image