{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeApplications #-}
module Ema.Class where
class Ema model route | route -> model where
encodeRoute :: model -> route -> FilePath
decodeRoute :: model -> FilePath -> Maybe route
allRoutes :: model -> [route]
default allRoutes :: (Bounded route, Enum route) => model -> [route]
allRoutes model
_ = [route
forall a. Bounded a => a
minBound .. route
forall a. Bounded a => a
maxBound]
instance Ema () () where
encodeRoute :: () -> () -> FilePath
encodeRoute () () = []
decodeRoute :: () -> FilePath -> Maybe ()
decodeRoute () = \case
[] -> () -> Maybe ()
forall a. a -> Maybe a
Just ()
FilePath
_ -> Maybe ()
forall a. Maybe a
Nothing
allRoutes :: () -> [()]
allRoutes () = OneItem [()] -> [()]
forall x. One x => OneItem x -> x
one ()