Last active
August 29, 2015 14:23
-
-
Save jkarni/948e59d2985d67c36453 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
-- first a separate class to interpret the access/permission DSL | |
class IsAccess a where | |
getAccess :: Proxy a -> Id -> Bool | |
-- ^ probably something quite different here. The two main options I see generally | |
-- are evaluating to some normal form (like AccessType) and not requiring Id, or | |
-- having Id and then directly evaluating to Bool | |
-- If you want to be allowed to require other values depending on the type (which I | |
-- think you do) you'd need an associated type synonym). | |
instance (IsAccess a, IsAccess b) => IsAccess (a :|| b) where | |
getAccess _ id = getAccess (Proxy :: Proxy a) id || getAccess (Proxy :: Proxy b) | |
-- and so on for :&&, etc. `Admin` etc. need to check the internals of `Id`, unless | |
-- you go down the route of evaluating to some normal form. | |
-- We wrap in `Access` just because of overlapping instances. | |
instance (IsAccess a, HasServer b) => HasServer (Access a :> b) where | |
type Server (a :> b) = b | |
route _ handler req respond = -- get `Id` from header and DB (like Entity Person) and do the appropriate thing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment