0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Elmのレコードでのエラーが分かりづらいとき

Posted at

Debug.todoはundefinedのようなもの

type alias Config =
    { hoge : Int
    , piyo : String
    }


config : Config
config =
    -- piyoが違うのでエラーになる
    { hoge = 5
    , piyo = 10
    }

下記のようにする。

config : Config
config =
    -- エラーが消える
    { hoge = 5
    , piyo = Debug.todo "" -- 10
    }

レコードでエラーが起きたときに、どのフィールドでエラーが起きたのか分かりづらいなと思っていたのですが、Debug.todoを使えばよかったんですね。

Debug.toStringで文字列にできる

config : Config
config =
    { hoge = 5
    , piyo = "abc"
    }


view : Model -> Html Msg
view model =
    text <| Debug.toString config

Debug.toStringも何故か忘れていました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?