[GHC] #14661: Cannot derive (newtype I a b = I (F a -> F b) deriving newtype Category) for type family F
GHC
ghc-devs at haskell.org
Fri Jan 12 16:35:39 UTC 2018
#14661: Cannot derive (newtype I a b = I (F a -> F b) deriving newtype Category)
for type family F
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.4.1-alpha1
Resolution: wontfix | Keywords:
| DerivingStrategies, deriving,
| TypeFamilies
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):
* status: new => closed
* resolution: => wontfix
Comment:
Apologies simonpj, comment:6 wouldn't have made sense except to
Iceland_jack, myself, and a handful of other people.
`DerivingVia` is the code name we're using to describe a work-in-progress
deriving strategy that we're developing, based on this
[https://skillsmatter.com/skillscasts/10934-lightning-talk-stolen-
instances-taste-just-fine HaskellX talk] that Iceland_jack gave. This
would allow you to write something of the form:
{{{#!hs
newtype Ixed a b = Ixed (Interp a -> Interp b)
deriving Category
via (WRAP InterpSym0 (->) a b)
}}}
Where `WRAP` is a separate data type that has exactly the right `Category`
instance that you'd want for `Ixed`. It would generate the following code:
{{{#!hs
instance Category Ixed where
id = coerce @(forall a. Ixed a a) @(forall a. WRAP InterpSym0 (->) a a)
id
(.) = coerce @(forall a b c. Ixed b c -> Ixed a b -> Ixed a c) @(forall
a b c. WRAP InterpSym0 (->) b c -> WRAP InterpSym0 (->) a b -> WRAP
InterpSym0 (->) a c) (.)
}}}
Another way of thinking about it is that it's an even more generalized
form of `GeneralizedNewtypeDeriving` where the user is allowed to specify
their own type to `coerce` from (instead of being required to use a
newtype's underlying representation type).
It's not fully documented at the moment, but we do have a WIP
specification [https://github.com/Icelandjack/deriving-
via/blob/06cb4fffbac68a7ca788ce1778f76c971906911e/paper/Specification_sketch.markdown
here] if you're curious.
Anyways, I'll opt to close this, since Iceland_jack seems OK with the idea
of using `DerivingVia` to accomplish this task.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14661#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list