{-# LANGUAGE DefaultSignatures #-}
module Web.Hyperbole.View.ViewId where
import Data.Kind (Type)
import GHC.Generics
import Web.Hyperbole.Data.Encoded as Encoded
class ViewId a where
type ViewState a :: Type
type ViewState a = ()
toViewId :: a -> Encoded
default toViewId :: (Generic a, GToEncoded (Rep a)) => a -> Encoded
toViewId = a -> Encoded
forall a. (Generic a, GToEncoded (Rep a)) => a -> Encoded
genericToEncoded
parseViewId :: Encoded -> Either String a
default parseViewId :: (Generic a, GFromEncoded (Rep a)) => Encoded -> Either String a
parseViewId = Encoded -> Either String a
forall a.
(Generic a, GFromEncoded (Rep a)) =>
Encoded -> Either String a
genericParseEncoded
instance ViewId () where
toViewId :: () -> Encoded
toViewId ()
_ = Encoded
forall a. Monoid a => a
mempty
parseViewId :: Encoded -> Either String ()
parseViewId Encoded
_ = () -> Either String ()
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()