[GHC] #16178: Brackets and splices should be overloaded like the static keyword

GHC ghc-devs at haskell.org
Mon Jan 14 11:15:48 UTC 2019


#16178: Brackets and splices should be overloaded like the static keyword
-------------------------------------+-------------------------------------
           Reporter:  mpickering     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.6.3
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
  TypedTemplateHaskell               |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 It's quite convenient that the `static` keyword is rebindable. To recap,
 if `e :: T` then `static e :: (IsStatic p) => p t`.

 It should also be possible rebind brackets and splices in the same manner.
 So we introduce two type classes `IsBracket` and `IsSplice`. Now quoting a
 term `e :: T` has type `e :: IsBracket p => p T` and the argument to a
 splice
 must have type `e :: IsSplice p => p T` which results in a value of type
 `T`.

 {{{
 class IsBracket p where
   fromBracket :: Code t -> p t

 class IsSplice p where
   toBracket :: p t -> Code t

 foo :: IsBracket p => p Int
 foo = [|| 5 ||]

 qux :: (IsSplice p, IsBracket p) => Int
 qux = $$(foo)
 }}}


 As an aside, arguably the `static` form should only be rebindable when
 `RebindableSyntax` is enabled but that boat seems to have sailed.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16178>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list