digitallyinduced/ihp

Refactor Code Generators to be more nice-looking again

开放

#1,171 创建于 2021年10月25日

 (7 条评论) (0 个反应) (0 位负责人)Haskell (221 个派生)batch import
good first issue

仓库指标

星标
 (5,285 个星标)
PR 合并指标
 (平均合并 11小时 20分钟) (30 天内合并 21 个 PR)

描述

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
        ...
|]

贡献者指南