[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Use a newtype `Code` for the return type of typed quotations (Proposal #195)

Marge Bot gitlab at gitlab.haskell.org
Mon Jul 20 22:37:46 UTC 2020



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
21cd7709 by Matthew Pickering at 2020-07-20T18:37:43-04:00
Use a newtype `Code` for the return type of typed quotations (Proposal #195)

There are three problems with the current API:

1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition
   of two type constructors. Doing so in your program involves making your own newtype and
   doing a lot of wrapping/unwrapping.

   For example, if I want to create a language which I can either run immediately or
   generate code from I could write the following with the new API. ::

      class Lang r where
        _int :: Int -> r Int
        _if  :: r Bool -> r a -> r a -> r a

      instance Lang Identity where
        _int = Identity
        _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f)

      instance Quote m => Lang (Code m) where
        _int = liftTyped
        _if cb ct cf = [|| if $$cb then $$ct else $$cf ||]

2. When doing code generation it is common to want to store code fragments in
   a map. When doing typed code generation, these code fragments contain a
   type index so it is desirable to store them in one of the parameterised
   map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from
   ``parameterized-utils``.

   ::

      compiler :: Env -> AST a -> Code Q a

      data AST a where ...
      data Ident a = ...

      type Env = MapF Ident (Code Q)

      newtype Code m a = Code (m (TExp a))

   In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``.
   Using one of these map types currently requires creating your own newtype and constantly
   wrapping every quotation and unwrapping it when using a splice. Achievable, but
   it creates even more syntactic noise than normal metaprogramming.

3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is
   easier. This is a weak reason but one everyone
   can surely agree with.

Updates text submodule.

- - - - -
2201250a by Moritz Angermann at 2020-07-20T18:37:44-04:00
Revert "AArch32 symbols only on aarch32."

This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a.

Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
6b47534d by Moritz Angermann at 2020-07-20T18:37:44-04:00
Revert "Fix (1)"

This reverts commit 7abffced01f5680efafe44f6be2733eab321b039.

Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
00f2aa19 by Moritz Angermann at 2020-07-20T18:37:44-04:00
Revert "better if guards."

This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e.

Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -
d114cd47 by Moritz Angermann at 2020-07-20T18:37:44-04:00
Revert "[linker/rtsSymbols] More linker symbols"

This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97.

Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com>

- - - - -


30 changed files:

- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Gen/Splice.hs
- docs/users_guide/exts/deriving_extra.rst
- docs/users_guide/exts/template_haskell.rst
- libraries/template-haskell/Language/Haskell/TH.hs
- + libraries/template-haskell/Language/Haskell/TH/CodeDo.hs
- libraries/template-haskell/Language/Haskell/TH/Lib.hs
- libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- libraries/template-haskell/changelog.md
- libraries/template-haskell/template-haskell.cabal.in
- libraries/text
- rts/RtsSymbols.c
- testsuite/tests/deriving/should_compile/drv-empty-data.stderr
- testsuite/tests/parser/should_compile/Proposal229f_instances.hs
- testsuite/tests/partial-sigs/should_compile/TypedSplice.hs
- testsuite/tests/partial-sigs/should_compile/TypedSplice.stderr
- testsuite/tests/quotes/T17857.hs
- testsuite/tests/th/T10945.stderr
- testsuite/tests/th/T11452.stderr
- testsuite/tests/th/T15471A.hs
- testsuite/tests/th/T15843.hs
- testsuite/tests/th/T16195A.hs
- testsuite/tests/th/T18121.hs
- testsuite/tests/th/T8577.stderr
- testsuite/tests/th/T8577a.hs
- testsuite/tests/th/TH_StringLift.hs
- testsuite/tests/th/TH_reifyLocalDefs.hs
- testsuite/tests/th/overloaded/T17839.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...d114cd4737b90cf4152662df008ec443955f19b5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e81d116a653b5259aeb290fb1e697efe3382a...d114cd4737b90cf4152662df008ec443955f19b5
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200720/666a85bf/attachment-0001.html>


More information about the ghc-commits mailing list