[Haskell-cafe] data type familly and makeLenses

Will Yager will.yager at gmail.com
Fri Mar 4 14:18:40 UTC 2022


Could you derive Generic and then use generic lenses?

> On Mar 4, 2022, at 06:04, PICCA Frederic-Emmanuel <frederic-emmanuel.picca at synchrotron-soleil.fr> wrote:
> 
> Hello, I defined a typeclass like this with a data familly
> 
> class HasConfig a where
>  data BinocularsConfig a :: *
> 
>  new :: (MonadIO m, MonadLogger m, MonadThrow m) => Maybe FilePath -> m (BinocularsConfig a)
>  getConfig :: Maybe FilePath -> IO (Either String (BinocularsConfig a))
>  combineWithCmdLineArgs :: BinocularsConfig a -> Maybe ConfigRange -> Maybe (Path Abs Dir) -> BinocularsConfig a
>  update :: (MonadIO m, MonadLogger m, MonadThrow m) => FilePath -> m (BinocularsConfig a)
> 
> the instance is for now
> 
> instance HasConfig PreConfig where
>  data BinocularsConfig PreConfig =
>    BinocularsPreConfig { _binocularsPreConfigProjectionType :: ProjectionType }
>                          deriving (Eq, Show)
> 
>   [...]
> 
> Since I use Ini to serialize/un-serialize the configuration, I need lens for this type
> 
> My question is how can I generate the like easily
> 
> makeLenses ''(BinocularsConfig PreConfig) does not work
> 
> thanks for considering
> 
> Frederic
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the Haskell-Cafe mailing list