Haskellのdoctest (ghci) の:{..:}中のletでincorrect indentation

こんな感じのdoctestを書いていると怒られた 😭

-- >>> :{
-- >>> let result = "good"
-- >>> "good"
-- >>> :}
-- "good"
### Failure in Foo.hs:364: expression `:{
 let result = "good"
 "good"
:}'
expected: "good"
 but got:
          <interactive>:436:2: error:
              parse error (possibly incorrect indentation or mismatched brackets)

let式を使うと(letにinを付けると)正しく実行された。

-- >>> :{
-- >>> let result = "good" in
-- >>> "good"
-- >>> :}
-- "good"

ちなみにこれもだめだった 😕

-- >>> :{
-- >>> let result = "good"
-- >>> return "good"
-- >>> :}
-- "good"

マジかよ ❗ ❗


参考までに、以下は「こんな感じ」の実例。

-- >>> :{
-- >>> let result = [z|
-- >>>               (do
-- >>>                 (def! x 10)
-- >>>                 (def! y (+ 10 x))
-- >>>                 (fn* (a) (+ x y)))
-- >>>              |] in
-- >>> case result of
-- >>>      [pp|(fn* (a) (+ 10 20))|] -> "good"
-- >>>      _ -> "bad: " <> readable result
-- >>> :}
-- "good"
### Failure in src/Maru/Eval.hs:364: expression `:{ilures: 0
 let result = [z|
               (do
                 (def! x 10)
                 (def! y (+ 10 x))
                 (fn* (a) (+ x y)))
              |]
 case result of
      [pp|(fn* (a) (+ 10 20))|] -> "good"
      _ -> "bad: " <> readable result
:}'
expected: "good"
 but got:
          <interactive>:441:2: error:
              parse error (possibly incorrect indentation or mismatched brackets)

筆者プロフィール

my-latest-logo

aiya000(あいや)

せつラボ 〜圏論の基本〜」 「せつラボ2~雲と天使と関手圏~」 「矢澤にこ先輩といっしょに代数!」を書いています!

強い静的型付けとテストを用いて、バグを防ぐのが好き。Haskell・TypeScript。