[GHC] #13368: Derive superclasses automatically if possible

GHC ghc-devs at haskell.org
Sun Aug 5 16:24:20 UTC 2018


#13368: Derive superclasses automatically if possible
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  feature request   |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:  wontfix           |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10607            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by songzh):

 I added a module `Data.Derive.Superclass` in derive-
 package[http://hackage.haskell.org/package/derive-topdown-0.0.2.0 which
 partially solve this problem.

 {{{
 #!div style="font-size: 80%"

   {{{#!haskell
 > newtype IO_ a = IO_ (IO a)
 > strategy_deriving_superclasses newtype_ ''MonadIO ''IO_

 You will get:

 >    strategy_deriving_superclasses newtype_ ''MonadIO ''IO_
 >  ======>
 >    deriving newtype instance MonadIO IO_
 >    deriving newtype instance Monad IO_
 >    deriving newtype instance Applicative IO_
 >    deriving newtype instance Functor IO_

 Appearently, Functor f => Applicative f => Monad f => MonadIO f

 > newtype F32 = F32 Float
 > newtype_deriving_superclasses ''RealFloat ''F32

 You will get:

 >    newtype_deriving_superclasses ''RealFloat ''F32
 >  ======>
 >    deriving newtype instance RealFloat F32
 >    deriving newtype instance RealFrac F32
 >    deriving newtype instance Real F32
 >    deriving newtype instance Num F32
 >    deriving newtype instance Ord F32
 >    deriving newtype instance Eq F32
 >    deriving newtype instance Fractional F32
 >    deriving newtype instance Floating F32
   }}}
 }}}

 Please try the package, if there are problem with it, please contact with
 me.

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


More information about the ghc-tickets mailing list