Skip to content

Factor out database #19

Description

@jerbaroo

Currently the database that this library interacts with is sqlite, and all operations run in IO.

I wonder if you would consider allowing the user to interact with a database of their choice? This would allow using databases other than sqlite, and it would also allow frontends (e.g. Miso/Reflex) to interact with a web server using GP.

This would mean instead of having operations like:

deleteById :: forall a id. (Entity a, Convertible id SqlValue) => Conn -> id -> IO ()

The operations would look like:

deleteById :: forall m a id. (MonadGP m, Entity a, Convertible id SqlValue) => Conn -> id -> m ()

Then, in order to ensure that existing library users aren't affected by the change:

instance MonadGP IO where
  deleteById = -- existing sqlite IO
  selectById = -- existing sqlite IO

In order to make it easier for those writing an instance of MonadGP the typeclass could be made more fine-grained, so you only have to write instance for the operations you want to use. Example:

class MonadGPDelete m where
  deleteById :: --

class MonadGPSelect m where
  selectById :: --

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions