Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type bondage
data ResourceId a = ResourceId Integer
data Image
data User
data Authorized a b = Authorized (ResourceId a)
data Create
data Read
data Update
data Delete
authorizeRead :: (ResourceId a)
-> (ResourceId User)
-> Authorized (ResourceId a) Main.Read
authorizeRead resourceId userId = undefined
readResource :: Authorized (ResourceId a) Main.Read
-> EitherT Text IO a
readResource (Authorized id) = undefined
deleteResource :: Authorized (ResourceId a) Delete
-> EitherT Text IO ()
deleteResource (Authorized id) = undefined
readImage :: (ResourceId Image)
-> (ResourceId User)
-> EitherT Text IO Image
readImage imageId userId = readResource $ authorizeRead imageId userId
-- this won't type check
deleteImage :: (ResourceId Image)
-> (ResourceId User)
-> EitherT Text IO ()
deleteImage imageId userId = deleteResource $ authorizeRead imageId userId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.