This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
================================================================================================= | |
| Mapping functions | | |
================================================================================================= | |
------------------------ | |
| One mapping function | | |
------------------------ | |
class Functor f where | |
map :: ∀ a b. (a -> b) -> f a -> f b (Covariant) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch15 where | |
import Prelude | |
import Data.Int (even, odd) | |
import Data.Foldable (class Foldable, foldl) | |
import Data.List (List(..), (:)) | |
import Data.String (length) | |
import Effect (Effect) | |
import Effect.Console (log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch17 where | |
( Age (..) | |
, FamilyAges(..) | |
, FamilyAgesRow | |
, Validation(..) | |
, Either(..) | |
, createFamilyAges | |
, test | |
) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch17Parser where | |
import Prelude | |
import Data.Either (Either(..)) | |
import Data.Maybe (Maybe(..)) | |
import Data.Tuple (Tuple(..)) | |
import Data.Array as A | |
import Data.Unfoldable as U | |
import Data.Traversable (class Traversable, sequence) | |
import Data.Generic.Rep (class Generic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch19 where | |
import Prelude | |
import Data.Generic.Rep (class Generic) | |
import Data.Show.Generic (genericShow) | |
import Effect (Effect) | |
import Effect.Console (log) | |
----------- | |
-- Maybe -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch19Parser where | |
import Prelude | |
import Data.Either (Either(..)) | |
import Data.Maybe (Maybe(..)) | |
import Data.Tuple (Tuple(..)) | |
import Data.Array as A | |
import Data.Unfoldable as U | |
import Data.Traversable (class Traversable, sequence) | |
import Data.Generic.Rep (class Generic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch19DateParser where | |
import Prelude | |
import Control.Alt (class Alt, (<|>)) | |
import Data.Array (cons) | |
import Data.CodePoint.Unicode (isDecDigit, isAlpha) | |
import Data.Either (Either(..)) | |
import Data.Generic.Rep (class Generic) | |
import Data.Int (fromString) | |
import Data.Maybe (Maybe(..), fromMaybe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch19SomeManyCombinators where | |
import Prelude | |
import Control.Alt (class Alt, (<|>)) | |
import Control.Lazy (class Lazy, defer) | |
import Data.Array as A | |
import Data.CodePoint.Unicode (isDecDigit, isAlpha) | |
import Data.Either (Either(..)) | |
import Data.Generic.Rep (class Generic) | |
import Data.Maybe (Maybe(..)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ch19RWS where | |
import Prelude | |
import Data.Tuple (Tuple(..)) | |
import Effect (Effect) | |
import Effect.Console (log) | |
-- rewrite Reader, Writer and State data types which are monads for your own reference | |
-- you might want to comment out the code |