Skip to content

ArulselvanMadhavan/haskell-first-principles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

06e0c71 · May 23, 2018

History

92 Commits
Oct 16, 2017
Oct 18, 2017
Oct 30, 2017
Oct 30, 2017
Nov 8, 2017
Nov 12, 2017
Feb 12, 2018
Mar 12, 2018
Mar 25, 2018
Mar 27, 2018
Oct 16, 2017
Mar 31, 2018
Apr 5, 2018
Apr 9, 2018
Apr 15, 2018
Apr 22, 2018
Apr 28, 2018
May 23, 2018
May 22, 2018
Oct 16, 2017
Oct 16, 2017
Oct 16, 2017
Oct 16, 2017
Oct 16, 2017
Oct 16, 2017
Oct 16, 2017
Nov 8, 2017
Mar 28, 2018
Nov 8, 2017
Apr 21, 2018

Repository files navigation

Haskell Handbook

Add package

stack install QuickCheck

Load Tests

stack ghci <project_name>:<test_module_name>

To make GHC notice changes to package.yaml

stack build

To enable QuasiQuotes

:set -ddump-splices

Monoid

Applied on a per operation basis

  1. Binary
  2. Associative
  3. Idenity

Semigroup

A monoid where the Identity property is left out.

Magma

Magma < Semigroup < Monoid

Functor

A way to apply a function over or around some structure that we don't want to alter.

Functor laws - <$> - Function application over a structure

fmap id = id
fmap (p . q) = (fmap p) . (fmap q)

Functor instances are unique for a given datatype as opposed to monoid which is unique per operation.

QuickCheck

  1. Arbitrary typeclass is used for generating values
  2. CoArbitrary typeclass is used for generating functions

Applicative

  1. Applicatives are monoidal functors.
class Functor f => Applicative f where
      pure :: a -> f a
      <*>  :: f (a -> b) -> f a -> f b
  1. <*> - is called "apply".
  2. Comparison with Functor
(<$>) :: Functor f
      => (a -> b) -> f a -> f b
(<*>) :: Applicative f
      => f (a -> b) -> f a -> f b

Applicative Laws

  1. Identity
pure id <*> v = v
  1. Composition
pure (.) <*> u <*> v <*> w =
     u <*> (v <*> w)
  1. Homomorphism
pure f <*> pure x = pure (f x)
  1. Interchange
u <*> pure y = pure ($ y) <*> u
  1. Applicative is just function application that preserves without doing anything other than combining the structure bits.
  2. Applicative can have more than one valid and lawful instance for a given datatype.
Applicative can be thought of characterizing Monoidal Functors in Haskell

Monad

Notes on Monad

Foldable

Notes on Foldable

Traversable

Notes on Traversable

TODO

  1. I haven't done Chapter16 Chapter Exercise 11.
  2. Chapter 21 - Tests for Exercise SkiFree are failing.
  3. Chapter 21 - Need to write Arbitrary Instance for Tree and finish the test.

Releases

No releases published

Packages

No packages published