Created
June 27, 2019 08:34
-
-
Save saurabhnanda/20df208f9dd89c1f21f931e42952d79a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Permission = PermA | PermB | PermC deriving (Eq, Show) | |
data EnsurePermissions (ps :: [Permission]) = EnsurePermissions | |
instance ( HasServer api context | |
) => HasServer (EnsurePermissions (ps :: [Permission]) :> api) context where | |
type ServerT (EnsurePermissions ps :> api) m = (() -> ServerT api m) | |
-- I want to convert the type `ps` to it's equivalent value in this function | |
route Proxy context subserver = undefined |
Solonarv
commented
Jun 27, 2019
Using singletons
:
{-# LANGUAGE
DataKinds,
FlexibleInstances,
ScopedTypeVariables,
TypeApplications
#-}
import Data.Singletons
data Permission = PermA | PermB | PermC
$(genSingletons ''Permission)
instance ( HasServer api context
, SingI ps
) => HasServer (EnsurePermissions (ps :: [Permission]) :> api) context where
type ServerT (EnsurePermissions ps :> api) m = (() -> ServerT api m)
route _ context subserver = ... fromSing (sing @ps) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment