ndmitchell / uniplate

Haskell library for simple, concise and fast generic operations.
Other
76 stars 8 forks source link

No instance Biplate [a] a? #20

Closed mitchellwrosen closed 8 years ago

mitchellwrosen commented 8 years ago

Hi, I'm curious why there's no Biplate [a] a instance defined in the library, just a Biplate [Char] Char one.

Thanks!

ndmitchell commented 8 years ago

An attempt at avoiding overlapping instances by ensuring they are all always concrete. Not sure it's a great idea or not though - I suspect GHC's instance checker could cope just fine.

mitchellwrosen commented 8 years ago

Ah, I see! There are also these:

(Data a, Data b, Uniplate b) => Biplate a b  
(Typeable a, Typeable b, Uniplate b, PlateAll a b) => Biplate a b

I think I was hitting something like no instance for Biplate (NonEmpty Foo) Foo and opened this ticket. Turns out I just needed to derive Data or Typeable

mitchellwrosen commented 8 years ago

Whoops, reopening this for a second. Now that NonEmpty is in base, would you accept a patch for this instance?

(PlateAll from to, Typeable from, Typeable to, Uniplate to) => PlateAll (NonEmpty from) to
ndmitchell commented 8 years ago

I certainly would, provided it had the CPP magic to not trigger on older versions. However, are you really using the Typeable variants of Uniplate? My experience is that sometimes they are slower than the Data variants, and always require more code. I'd actually been considering deleting them.

mitchellwrosen commented 8 years ago

I was using the Typeable variants, yeah, because I had a function inside the data structure and there's no Data instance for a -> b. However, I realized the PlateAll instance for NonEmpty was not really needed, as I could wrangle something together with Str.

If you want to remove the Typeable variants to clean up the API, by all means!

mitchellwrosen commented 8 years ago

This is resolved from my end, so closing