[Haskell-cafe] Is there a way to make this code compose generic ?

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Wed Apr 9 14:41:49 UTC 2025


Another question related to this one

> data ExampleData

> instance DataSource ExampleData where
>   data DataSourceT k ExampleData = DataSource'ExampleData
>     (DataSourceT k BaseData)
>     (DataSourceT k BaseData)
>     (DataSourceT k BaseData)
>     (DataSourceT k BaseData)
>     (DataSourceT k BaseData)
>     deriving Generic
>   ds'Shape = generic'ds'Shape
>   withDataSourceP = generic'withDataSourceP
> 

Do you think that it is possible to derive the

DataSourceT Acq and Path from the ExampleData type


data ExampleData = ExampleData A B

it seems mechanical to me

data DataSourceT k ExampleDAta
  = DataSource'ExampleData
    (DataSourceT k A)
    (DataSourceT k B)

I tryed with HKD like this

-- "Higher-Kinded Data"                                                                                                                    
type family HKD f a where
  HKD Identity a = a
  HKD f        a = f a         

data ExampleData' f
  = ExampleData
   (HKD f A)
   (HKD f B)

where

but then I do not know howto define the type family for DataSourceT with this ExampleData' f

Cheers

Fred


More information about the Haskell-Cafe mailing list