persistent-template-classy alternatives and similar packages
Based on the "persistent" category.
Alternatively, view persistent-template-classy alternatives based on common mentions on social networks and blogs.
-
persistent-redis
Persistence interface for Haskell allowing multiple storage methods. -
persistent-database-url
Parse DATABASE_URL into configuration types for Persistent -
persistent-odbc
uses persistent connecting via hdbc odbc -
persistent-relational-record
Persistent adapter for Haskell Relational Record -
persistent-mtl
Monad transformers for the persistent library -
persistent-pagination
Efficient and correct pagination! -
persistent-mysql-haskell
Persistence interface for Haskell allowing multiple storage methods. -
persistent-spatial
Spatially indexed type for storing ceigraphic coordinates. -
persistent-protobuf
a Template-Haskell routine to ease integration between Persistent and protobufs -
persistent-generic
Generic facilities for working with Persistent classes -
persistent-zookeeper
Persistence interface for Haskell allowing multiple storage methods.
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of persistent-template-classy or a related project?
README
persistent-template-classy
Generate classy lens for your Persistent fields. For example:
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
import Control.Lens (Lens', (^.), lens)
import Control.Monad.IO.Class (liftIO)
import Database.Persist
import Database.Persist.Sqlite
import Database.Persist.TH
import Database.Persist.TH.Classy
$(mkClassyClass "name")
$(mkClassyClass "age")
$(mkClassyClass "title")
$(mkClassyClass "authorId")
share
[mkPersist sqlSettings, mkMigrate "migrateAll", mkClassyInstances]
[persistLowerCase|
Person
name String
age Int Maybe
deriving Show
BlogPost
title String
authorId PersonId
deriving Show
|]
main :: IO ()
main =
runSqlite ":memory:" $ do
runMigration migrateAll
let johnDoe = Person "John Doe" $ Just 35
johnId <- insert johnDoe
liftIO $ print $ johnDoe ^. name
liftIO $ print $ johnDoe ^. age
let post = BlogPost "My fr1st p0st" johnId
liftIO $ print $ post ^. title
This would essentially generate this additional code:
class HasName ev a | ev -> a where
name :: Lens' ev a
class HasAge ev a | ev -> a where
age :: Lens' ev a
class HasTitle ev a | ev -> a where
title :: Lens' ev a
class HasAuthorId ev a | ev -> a where
authorId :: Lens' ev a
instance HasName Person String where
name = (lens personName) (\ x y -> x {personName = y})
instance HasAge Person Int where
age = (lens personAge) (\ x y -> x {personAge = y})
instance HasTitle BlogPost String where
title = (lens blogPostTitle) (\ x y -> x {blogPostTitle = y})
instance HasAuthorId BlogPost PersonId where
authorId
= (lens blogPostAuthorId) (\ x y -> x {blogPostAuthorId = y})
Class-generation is separated from instance-generation because it's wise to keep it in a single place in your project and reuse with a non-persistent code.