
Hi all, I'm working on updating persistent-template for ghc-8.0 and reading the migration guide: https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#template-haskell-2.11.0.... specifically the bit that says:
* the DataD, NewtypeD, DataInstD, and NewtypeInstD constructors have a new field `Maybe Kind` (#10828), and take a `CxtQ` instead of a `[Name]` for the derived classes (#10819). If you don't know what to do, use `Nothing` for the kind signature, and `cxt []` for the derived classes.
Using `Nothing` as suggested is working out well enough, but I'm a bit befuddled by the change from `[Name]` to `CtxQ` and the usage of `ctx []`. I can't seem to find *any* function named `ctx`. Any light people may be about to shed on this would be much appreciated. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Tue, Apr 12, 2016 at 02:22:23PM +1000, Erik de Castro Lopo wrote:
Date: Tue, 12 Apr 2016 14:22:23 +1000 From: Erik de Castro Lopo
To: ghc-devs@haskell.org Subject: TH changes for ghc 8.0 Hi all,
I'm working on updating persistent-template for ghc-8.0 and reading the migration guide:
https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#template-haskell-2.11.0....
specifically the bit that says:
* the DataD, NewtypeD, DataInstD, and NewtypeInstD constructors have a new field `Maybe Kind` (#10828), and take a `CxtQ` instead of a `[Name]` for the derived classes (#10819). If you don't know what to do, use `Nothing` for the kind signature, and `cxt []` for the derived classes.
Using `Nothing` as suggested is working out well enough, but I'm a bit befuddled by the change from `[Name]` to `CtxQ` and the usage of `ctx []`. I can't seem to find *any* function named `ctx`.
the docs say `cxt`, not `ctx`. not sure what that means either. (-: cheers, m.

On 12 April 2016 at 07:36, Matthias Fischmann
On Tue, Apr 12, 2016 at 02:22:23PM +1000, Erik de Castro Lopo wrote:
Date: Tue, 12 Apr 2016 14:22:23 +1000 From: Erik de Castro Lopo
To: ghc-devs@haskell.org Subject: TH changes for ghc 8.0 Hi all,
I'm working on updating persistent-template for ghc-8.0 and reading the migration guide:
https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#template-haskell-2.11.0....
specifically the bit that says:
* the DataD, NewtypeD, DataInstD, and NewtypeInstD constructors have a new field `Maybe Kind` (#10828), and take a `CxtQ` instead of a `[Name]` for the derived classes (#10819). If you don't know what to do, use `Nothing` for the kind signature, and `cxt []` for the derived classes.
Using `Nothing` as suggested is working out well enough, but I'm a bit befuddled by the change from `[Name]` to `CtxQ` and the usage of `ctx []`. I can't seem to find *any* function named `ctx`.
the docs say `cxt`, not `ctx`.
not sure what that means either. (-:
That function does exist for me in rc2: cxt :: [PredQ] -> CxtQ Erik

Erik Hesselink wrote:
That function does exist for me in rc2:
cxt :: [PredQ] -> CxtQ
Ah, there is it is! But I'm trying to write code that works with ghc-7.10 *and* ghc-8.0 (yes, I'm using CPP in all its ugly glory), but if I've got code that works with ghc-7.10 (the first type signature below):
- dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ + dataD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
how do I convert it to the second? Adding a `Nothing` for the `Maybe Kind` argument is easy, but if the old code has `[Name]`, how do I convert it to a `CxtQ`. The `cxt` function won't do it. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

mapM conT :: [Name] -> Q [Type] :: [Name] -> Q [Pred] :: [Name] -> CxtQ Those `Name`s are Class names, which are Type constructors, hence `conT` Christiaan On 04/12/2016 10:17 AM, Erik de Castro Lopo wrote:
Erik Hesselink wrote:
That function does exist for me in rc2:
cxt :: [PredQ] -> CxtQ
Ah, there is it is!
But I'm trying to write code that works with ghc-7.10 *and* ghc-8.0 (yes, I'm using CPP in all its ugly glory), but if I've got code that works with ghc-7.10 (the first type signature below):
- dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ + dataD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
how do I convert it to the second? Adding a `Nothing` for the `Maybe Kind` argument is easy, but if the old code has `[Name]`, how do I convert it to a `CxtQ`. The `cxt` function won't do it.
Erik

Christiaan Baaij wrote:
mapM conT :: [Name] -> Q [Type] :: [Name] -> Q [Pred] :: [Name] -> CxtQ
Those `Name`s are Class names, which are Type constructors, hence `conT`
Thanks Christiaan, thats got it for me. I'll update the migration guide as well. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

Erik de Castro Lopo
Christiaan Baaij wrote:
mapM conT :: [Name] -> Q [Type] :: [Name] -> Q [Pred] :: [Name] -> CxtQ
Those `Name`s are Class names, which are Type constructors, hence `conT`
Thanks Christiaan, thats got it for me. I'll update the migration guide as well.
Thanks Erik! Cheers, - Ben
participants (5)
-
Ben Gamari
-
Christiaan Baaij
-
Erik de Castro Lopo
-
Erik Hesselink
-
Matthias Fischmann