digitallyinduced/ihp

Refactor Code Generators to be more nice-looking again

オープン

#1,171 opened on 2021/10/25

 (7 件のコメント) (0 件のリアクション) (0 人の担当者)Haskell (221 件のフォーク)batch import
good first issue

Repository metrics

Stars
 (5,285 個のスター)
PR merge metrics
 (平均マージ 11h 20m) (30d で 21 merged PRs)

説明

If you compare the old PHP-based code generators with the newer Haskell-based one's , the PHP-based code gen's have much more readable code.

One low hanging fruit is to replace the normal haskell strings with https://hackage.haskell.org/package/neat-interpolation-0.5.1.2/docs/NeatInterpolation.html

Basically replacing code like this:

indexAction =
            ""
            <> "    action " <> pluralName <> "Action = do\n"
            <> (if paginationEnabled
                then   "        (" <> modelVariablePlural <> "Q, pagination) <- query @" <> model <> " |> paginate\n"
                    <> "        " <> modelVariablePlural <> " <- " <> modelVariablePlural <> "Q |> fetch\n"
                else "        " <> modelVariablePlural <> " <- query @" <> model <> " |> fetch\n"
            )
            <> "        render IndexView { .. }\n"

With this:

indexAction = [text|
    action #{pluralName}Action = do
        ...
|]

コントリビューターガイド