LoginSignup
12
2

More than 5 years have passed since last update.

[Elm]elm-formatでexposeする関数を整理する

Last updated at Posted at 2018-10-13

module documentを書いておくとelm-formatさんはいい感じにexposeする関数を並べてくれる

つまりこう!
image.png

elm 0.19.0
elm-format-0.19 0.8.0

前置き

elm-formatはElmの楽しいフォーマッターです。フォーマッターがなければ開発環境ではない世の中ですので当然ほとんどの人はフォーマッターを使用していろいろな言語を書いていると思いますが、中でもかなーり書き換えてきます(他言語の経験があまりないので当社比です)

exposing allは許されないの図

ちなみにElm自体の作者は使ってないことでも有名です(要出典)

問題

elm-formatは勝手にmodule exposingをアルファベット順に並び替える
image.png

multi line

image.png

single line

どっちにしろみにくいですね。強制的にアルファベット順になるのでいくら並び替えようとelm-formatかけた時点で無意味です

解決策

module documentを書きます

module Select exposing
    ( beforeIf, afterIf
    , by, head, last
    , all, allBefore, allAfter
    )

{-| module documentはmodule文とimport文の間に書けるmulti line commentのこと

@docs beforeIf, afterIf
@docs by, head, last
@docs all, allBefore, allAfter

-}

import Types exposing (SelectList(..), reverseAppend, toList)

@docsごとに改行して並び替えてくれるようになります。

追加TIPS

gif撮ってて気づいたんですがdocsある状態でexposing allを書き換えるとdocsあるやつだけexposing内に展開してくれるようになってます。ました。書き得じゃん

追記

docsに追加するだけでexpose追加されるようになってました

宣伝

elm-jpコミュニティでは公式ガイドの翻訳活動してます

進捗的に半分いってて、レビューしてくれる人がわたしとヤギの人だけで辛いし見落としがあるのでレビュアー募集してます

Elmのことわかんなくて大丈夫です。

12
2
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
12
2