[GHC] #11785: Kinds should be treated like types in TcSplice

#11785: Kinds should be treated like types in TcSplice -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Template | Version: 8.1 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- !TcSplice handles kinds differently than types. Now that they are the same, it's probably best to rewrite this code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Kinds should be treated like types in TcSplice -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: RyanGlScott (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Kinds should be treated like types in TcSplice -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Another place we should unify the treatment of `Type`s and `Kind`s is `DsMeta`. We have both `repLTy` and `repLKind`, but the latter covers far fewer things than the former, which has led to bugs like #13781. Sadly, accomplishing this requires more work than you'd believe, since `repLTy` returns a `TypeQ`, whereas `repLKind` returns a pure `Kind`. In other words, we'd have to go through and purify `repLTy`, as well as every function it calls which is also monadic (see https://phabricator.haskell.org/D3627#103117). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Kinds should be treated like types in TcSplice -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * keywords: => TypeInType -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Merge types and kinds in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Actually, there's another way to go about this. Instead of making more things pure, we could make more things monadic. This can be accomplished with the following combinator: {{{#!hs bindCore :: DsM (Core (TH.Q a)) -> (Core a -> DsM (Core (TH.Q b))) -> DsM (Core (TH.Q b)) bindCore dsma f = do { cqa@(MkC qa) <- dsma ; loc <- getSrcSpanDs ; a_name <- newNameAt (mkVarOccFS (fsLit "a")) loc ; let [a_ty] = tcTyConAppArgs (exprType qa) ; let a_id = mkLocalId (localiseName a_name) a_ty ca = MkC (Var a_id) ; MkC qb <- f ca ; let [b_ty] = tcTyConAppArgs (exprType qb) ; repBindQ a_ty b_ty cqa (MkC (Lam a_id qb)) } }}} With `bindCore`, we can retrofit existing uses of `repLKind` with `repLTy`. Here's one example: {{{#!diff diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index c679981..8acc6eb 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -1043,8 +1044,9 @@ repTy (HsEqTy t1 t2) = do repTapps eq [t1', t2'] repTy (HsKindSig t k) = do t1 <- repLTy t - k1 <- repLKind k - repTSig t1 k1 + bindCore (repLTy k) $ repTSig t1 + -- k1 <- repLKind k + -- repTSig t1 k1 repTy (HsSpliceTy splice _) = repSplice splice repTy (HsExplicitListTy _ _ tys) = do tys1 <- repLTys tys }}} It's somewhat unsavory, but it prevents us from having to change a truckload of combinators in `Language.Haskell.TH.Lib` to take `KindQ` as an argument instead of `Kind`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Merge types and kinds in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3751 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3751 Comment: Phab:D3751 addresses the `DsMeta` portion of this ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Merge types and kinds in Template Haskell
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: task | Status: patch
Priority: normal | Milestone:
Component: Template Haskell | Version: 8.1
Resolution: | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3751
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#11785: Merge types and kinds in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3751 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I looked into completing the `TcSplice` portion of this ticket recently. While making the change was simple enough, many reified kinds became a lot noisier due to the symptoms described in #14060. It'd be nice to fix #14060 first so as not to regress the quality of reified kinds. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Merge types and kinds in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: patch Priority: normal | Milestone: Component: Template Haskell | Version: 8.1 Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3751, Wiki Page: | Phab:D3854 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: Phab:D3751 => Phab:D3751, Phab:D3854 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11785: Merge types and kinds in Template Haskell
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: task | Status: patch
Priority: normal | Milestone:
Component: Template Haskell | Version: 8.1
Resolution: | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3751,
Wiki Page: | Phab:D3854
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#11785: Merge types and kinds in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: task | Status: closed Priority: normal | Milestone: 8.4.1 Component: Template Haskell | Version: 8.1 Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3751, Wiki Page: | Phab:D3854 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11785#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC