data type or family inside effect - Polysemy

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

drlkf

hello,
i would like to create an effect that requires a data type to be implemented in the interpreter in order to function e.g

data Cache c :: Effect where
  type Key = ...
  GetCacheKey :: Cache c m Key

but i'm not sure what to use, it seems like type families or data families would do the trick but i'm a bit lost on these concepts on their own, let alone their interaction with polysemy

TheMatten

drlkf said:

hello,
i would like to create an effect that requires a data type to be implemented in the interpreter in order to function e.g

data Cache c :: Effect where
  type Key = ...
  GetCacheKey :: Cache c m Key

but i'm not sure what to use, it seems like type families or data families would do the trick but i'm a bit lost on these concepts on their own, let alone their interaction with polysemy

What should the Key depend on (e.g. c)?
Would be great to have some example of a specific one

drlkf

not c, but i see what you mean, i guess it should be a parameter of Cache then?
i guess one example would be an interpreter for file cache that would have FilePath as Key, when a redis cache would have a ByteString, something like that