Start working on the (versioned) OPDS catalog
This commit is contained in:
24
src/Data/Versioned.hs
Normal file
24
src/Data/Versioned.hs
Normal file
@ -0,0 +1,24 @@
|
||||
{-# Language KindSignatures #-}
|
||||
{-# Language DataKinds #-}
|
||||
{-# Language DefaultSignatures #-}
|
||||
{-# Language MultiParamTypeClasses #-}
|
||||
{-# Language FunctionalDependencies #-}
|
||||
module Data.Versioned where
|
||||
|
||||
import GHC.TypeLits
|
||||
import ClassyPrelude
|
||||
import Data.Generics.Product
|
||||
|
||||
newtype Versioned (v :: Nat) a = Versioned a deriving (Show)
|
||||
|
||||
instance Functor (Versioned v) where
|
||||
fmap f (Versioned a) = Versioned (f a)
|
||||
|
||||
instance Applicative (Versioned v) where
|
||||
pure = Versioned
|
||||
(Versioned f) <*> (Versioned a) = Versioned (f a)
|
||||
|
||||
class Migrate a b | b -> a where
|
||||
migrate :: a -> b
|
||||
default migrate :: (Subtype b a) => a -> b
|
||||
migrate = upcast
|
Reference in New Issue
Block a user