Ok, I think I now succeeded in pushing my patches to darcs.haskell.org, along with all the patches pushed so far to the repos we've cloned (ghc, ghc-prim and base).
Cheers, Pedro 2010/10/25 José Pedro Magalhães <[email protected]> > Hi, > > Currently I have all the generics stuff in GHC.Generics in ghc-prim, but I > removed its export from GHC.Base, so no name clashes occur anymore. > > For my implementation I'm mostly following what's already there for the > current generics stuff. So, previously, types/Generics.lhs took care of > generating the binders for generic representations. I'm currently generating > the representations there, but I don't want them to be just binders: I want > them to be instances. > Previously, a type data D = D triggered the generation of binders > > $gfromD = ... >> $gtoD = ... >> > > Now, what I actually want is to generate an instance of the form > > instance Representable0 D where >> type instance Rep D = ... >> from0 D = ... >> to0 (...) = D >> > > (Whether the final implementation will use associated types or MPTCs is > still open for debate.) The stuff generated in types/Generics.lhs is used in > typecheck/TcDeriv.lhs. Previously, things like $gfromD were just returned as > extra top-level bindings, together with generated instance declarations. > Now, we no longer need top-level bindings (I think), but we do need to > return extra instances. These are the representable instances, and will be > generated even if there are no deriving clauses in the program. (When there > are deriving clauses for generic classes, I think this is where a generic > instance will be added too, but I'm not at that stage yet.) > > So far so good, and I managed to add some form of Representable0 instances > (function genGenericRepBinds in TcDeriv.lhs). Problem is, when compiling a > file with -XGenerics (to enable the generation of generic representations), > I still get complaints of lacking "explicit or default" methods, even though > those are generated: > > ==================== Derived instances ==================== >> InstInfo: GHC.Generics.Representable0 >> Main.A >> (GHC.Generics.D1 >> GHC.Generics.NoSelector >> (GHC.Generics.C1 GHC.Generics.NoSelector GHC.Generics.V1) >> t_a) >> { GHC.Generics.from0 _ >> = GHC.Generics.M1 >> (GHC.Err.error >> "No generic representation for empty datatype Main.A") >> GHC.Generics.to0 (GHC.Generics.M1 _) >> = GHC.Err.error "No values for empty datatype Main.A" } >> >> >> >> test/Main.hs:1:1: >> Warning: No explicit method nor default method for >> `GHC.Generics.from0' >> In the instance declaration for `GHC.Generics.Representable0 >> A >> (GHC.Generics.D1 >> GHC.Generics.NoSelector >> (GHC.Generics.C1 >> GHC.Generics.NoSelector GHC.Generics.V1) >> t_a)' >> >> test/Main.hs:1:1: >> Warning: No explicit method nor default method for `GHC.Generics.to0' >> In the instance declaration for `GHC.Generics.Representable0 >> A >> (GHC.Generics.D1 >> GHC.Generics.NoSelector >> (GHC.Generics.C1 >> GHC.Generics.NoSelector GHC.Generics.V1) >> t_a)' >> > > Also, if I have more than one datatype, I start getting > > /tmp/ghc28844_0/ghc28844_0.s: Assembler messages: >> >> /tmp/ghc28844_0/ghc28844_0.s:405:0: >> Error: symbol `ghczmprim_GHCziGenerics_Representable0_closure' is >> already defined >> > > So I'm clearly doing something wrong when generating my Representable0 > instances... > > Also, for the meta-information I will need to generate (empty) datatypes, > which should not be visible for the user. How can I do this? Currently I see > how to generate bindings for values and functions, but now how to declare > new types. Would TcDeriv.lhs be the appropriate place for this? Note that > these auxiliary types do not need generic representations. > > I do not have an account on darcs.haskell.org yet, so I'm attaching the > patches with the changes I've done so far. > > Thanks, > Pedro > >
_______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
