[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
Thu Jan 11 20:35:23 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: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.4.1-alpha1
Resolution: | 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: |
-------------------------------------+-------------------------------------
Comment (by Iceland_jack):
This can be derived (clunkily) with GND + `singletons`
{{{#!hs
import Data.Singletons
type Cat ob = ob -> ob -> Type
newtype WRAP :: (k' ~> k) -> (Cat k -> Cat k) where
WRAP :: cat (f@@a) (f@@b)
-> WRAP f cat a b
instance Category cat => Category (WRAP f cat) where
id :: forall a. WRAP f cat a a
id = WRAP (id @cat @(f@@a))
(.) :: forall b c a. WRAP f cat b c -> WRAP f cat a b -> WRAP f cat a c
WRAP f . WRAP g = WRAP ((.) @cat @(f@@b) @(f@@c) @(f@@a) f g)
data InterpSym0 :: TY ~> Type
type instance InterpSym0 @@ ty = Interp ty
}}}
+
{{{#!hs
newtype Ixed a b = Ixed (WRAP InterpSym0 (->) a b)
deriving newtype Category
}}}
or with `-XDerivingVia`
{{{#!hs
newtype Ixed a b = Ixed (Interp a -> Interp b)
deriving Category
via (WRAP InterpSym0 (->) a b)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14661#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list