モナドドリル サポートページ
https://doujin.kakkun61.com/monad-drill
正誤表
table:正誤表
ページ 問題 誤 正
17 5 runReader runState
模範解答
ページ 2
問題 1 2
問題 2 False
問題 3 3
評価戦略を考慮して 1 + 2 でも正解です、以降解答では行き止まりで記載します
問題 4 Nothing
問題 5 Identity 3
問題 6 Identity Nothing
問題 7 "hello"
問題 8 Right True
問題 9 8
ページ 3
問題 1 2
問題 2 False
問題 3 3
問題 4 Nothing
問題 5 Just 3
問題 6 Just Nothing
問題 7 "hello"
問題 8 Right True
問題 9 8
ページ 4
問題 1 2
問題 2 False
問題 3 3
問題 4 Nothing
問題 5 Right 3
問題 6 Right Nothing
問題 7 "hello"
問題 8 Right True
問題 9 8
ページ 5
問題 1 2
問題 2 False
問題 3 3
問題 4 Nothing
問題 5 [3]
問題 6 [Nothing]
問題 7 "hello"
問題 8 [True]
問題 9 8
ページ 6
問題 1 Identity 2 :: Identity Int
厳密には Int ではなく Num a => a ですが、本書では Int とします
問題 2 Identity False :: Identity Bool
問題 3 Identity "hello" :: Identity String
問題 4 Identity 3 :: Identity Int
問題 5 Identity 3 :: Identity Int
問題 6 Identity (Identity 1) :: Identity (Identity Int)
問題 7 Identity "4hello" :: Identity String
問題 8 Identity 6 :: Identity Int
問題 9 Identity 10 :: Identity Int
ページ 7
問題 1 Just 2 :: Maybe Int
問題 2 Just False :: Maybe Bool
問題 3 Just "hello" :: Maybe String
問題 4 Just 3 :: Maybe Int
問題 5 Just 3 :: Maybe Int
問題 6 Just (Just 1) :: Maybe (Maybe Int)
問題 7 Just "4hello" :: Maybe String
問題 8 Just 6 :: Maybe Int
問題 9 Just 14 :: Maybe Int
ページ 8
問題 1 Right 2 :: Either a Int
問題 2 Right False :: Either a Bool
問題 3 Right "hello" :: Either a String
問題 4 Right 3 :: Either a Int
問題 5 Right 3 :: Either a Int
問題 6 Right (Right 1) :: Either a (Either a Int)
問題 7 Right "4hello" :: Either a String
問題 8 Right 6 :: Either a Int
問題 9 Right 14 :: Either a Int
ページ 9
問題 1 [2] :: [Int]
問題 2 [False] :: [Bool]
問題 3 ["hello"] :: [String]
問題 4 [3] :: [Int]
問題 5 [3] :: [Int]
問題 6 [[1]] :: [[Int]]
問題 7 ["4hello"] :: [String]
問題 8 [6] :: [Int]
問題 9 [14] :: [Int]
ページ 10
問題 1 Nothing :: Maybe a
問題 2 Nothing :: Maybe a
問題 3 Nothing :: Maybe Int
問題 4 Just Nothing :: Maybe (Maybe a)
問題 5 Just Nothing :: Maybe (Maybe a)
問題 6 Nothing :: Maybe a
問題 7 Nothing :: Maybe String
問題 8 Nothing :: Maybe Int
ページ 11
問題 1 Left "error" :: Either String a
問題 2 Left 2 :: Either Int a
問題 3 Left '?' :: Either Char Int
問題 4 Right (Left "hello") :: Either a (Either String b)
問題 5 Right (Left 6) :: Either a (Either Int b)
問題 6 Left 7 :: Either Int a
問題 7 Left 8 :: Either Int String
問題 8 Left 9 :: Either Int Int
ページ 12
問題 1 [] :: [a]
問題 2 [] :: [a]
問題 3 [] :: [Int]
問題 4 [[]] :: [[a]]
問題 5 [[]] :: [[a]]
問題 6 [] :: [a]
問題 7 [] :: [String]
問題 8 [] :: [Int]
ページ 13
問題 1 Left "hello" :: Either String a
問題 2 Right 2 :: Either String Int
問題 3 型エラー:"hello" と 2 の部分の型は同じでなければならない
問題 4 Left 4 :: Either Int a
問題 5 Left 4 :: Either Int Int
問題 6 Right 6 :: Either a Int
問題 7 Left "hello" :: Either String a
ページ 14
問題 1 [1] :: [Int]
問題 2 [2, 4, 6] :: [Int]
問題 3 [3, 5, 7] :: [Int]
問題 4 [1, 11, 2, 12] :: [Int]
問題 5 [3, 4, 5, 6, 8, 10] :: [Int]
問題 6 [1, 1, 2, 1, 2, 3] :: [Int]
問題 7 [] :: [String]
ページ 15
問題 1 Identity 1
問題 2 Nothing >>= \a -> Just a
Nothing >>= (\a -> Just a) と同じです
問題 3 Right 1 >>= \a -> Left a
問題 4 [1 .. 3] >>= \a -> [2 .. 5] >>= \b -> [(a, b)]
問題 5 Identity 4 >>= \a -> Identity (a + 1) >>= \b -> Identity (a + b + 2) >>= \c -> Identity (c + 3)
ページ 16
問題 1 3 :: Int
問題 2 15 :: Int
問題 3 18 :: Int
問題 4 18 :: Int
問題 5 "helloFalse" :: String
問題 6 10 :: Int
ページ 17
問題 1 1 :: Int
問題 2 () :: ()
問題 3 15 :: Int
問題 4 0 :: Int
問題 5 18 :: Int
ページ 18
問題 1 何も表示されない
問題 2
code:txt
hello
問題 3
code:txt
hello
問題 4
code:txt
hello
問題 5
code:txt
hello world
問題 6
code:txt
hello
ページ 19
ステップ 1
問題 1 2
問題 2 Nothing
問題 3 Right 3
問題 4 "hello"
ステップ 2
問題 1 Nothing :: Maybe Int
問題 2 Right 3 :: Either a Int
問題 3 Right (Left "hello") :: Either a (Either String b)
問題 4 型エラー:"hello" と 2 の部分の型は同じでなければならない
問題 5 [3, 4, 5, 6, 8, 10] :: [Int]
問題 6 15 :: Int
問題 7 18 :: Int