summaryrefslogtreecommitdiff
path: root/Haskell-book/15/Madness.hs
blob: 9d6aa340a48f1d8edbf2b295edd7bf8eaf90bee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Madness where

import Data.Monoid

type Verb = String
type Adjective = String
type Adverb = String
type Noun = String
type Exclamation = String

madlibbin' :: Exclamation
           -> Adverb
           -> Noun
           -> Adjective
           -> String
madlibbin' e adv noun adj =
    e <> "! he said " <>
    adv <> " as he jumped into his car " <>
    noun <> " and drove off with his " <>
    adj <> " wife."

madlibbinBetter' :: Exclamation
                 -> Adverb
                 -> Noun
                 -> Adjective
                 -> String
madlibbinBetter' e adv noun adj =
    mconcat [ e
            , "! he said "
            ,  adv
            , " as he jumped into his car "
            , noun
            , " and drove off with his "
            , adj
            , " wife."
            ]