[GHC] #16027: Cannot use DefaultSignatures for TypeFamiles

#16027: Cannot use DefaultSignatures for TypeFamiles -------------------------------------+------------------------------------- Reporter: Ericson2314 | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 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: -------------------------------------+------------------------------------- I'm surprised there wasn't a ticket for this. Maybe I just couldn't find it. In short, I want to do something like: {{{ class Monad m => MyMonad m where type AssociatedMonad m :: Type -> Type default type AssociatedMonad m :: (m ~ t m', MonadTrans t, MyMonad m') => Type -> Type type AssociatedMonad (t m') = t (AssociatedMonad m') fun :: Foo -> m () default fun :: (m ~ t m', MonadTrans t, MyMonad m') => Foo -> m () fun = lift . fun }}} The syntax is a bit weird, but I hope in the process of implementing constrained type families the syntax properly analogous to the term-level would shake itself out. The use-case, like the normal method original, is to assist with monad transformer boilerplate. {{{MonadTrans}}} wouldn't be enough, but {{{MFunctor}}} from mmorph might be depending on the method using the associated type. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16027 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16027: Cannot use DefaultSignatures for TypeFamiles -------------------------------------+------------------------------------- Reporter: Ericson2314 | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 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): Until constrained type families are implemented (which likely won't be for a good while), you can do this: {{{#!hs class Monad m => MyMonad m where type AssociatedMonad m :: Type -> Type type AssociatedMonad m = DefaultAssociatedMonad m fun :: Foo -> m () default fun :: (m ~ t m', MonadTrans t, MyMonad m') => Foo -> m () fun = lift . fun type family DefaultAssociatedMonad (m :: Type -> Type) :: Type -> Type where DefaultAssociatedMonad (t m') = t (AssociatedMonad m') }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16027#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16027: Cannot use DefaultSignatures for TypeFamiles -------------------------------------+------------------------------------- Reporter: Ericson2314 | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.2 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 Ericson2314): @RyanGlScott nice trick! Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16027#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC