Module to manage access to a node in the IR. This is only used to declare access levels not to enforce them. Enforcement can be done through the helper functions withPublicAccess and withPrivateAccess but it's up to the consumer of the API to call the right function.
{ access : Access
, value : a
}
Type that represents different access levels.
Public or private access.
public : a -> AccessControlled a
Mark a node as public access. Actors with both public and private access are allowed to see.
private : a -> AccessControlled a
Mark a node as private access. Only actors with private access level can see.
withPublicAccess : AccessControlled a -> Maybe a
Get the value with public access level. Will return Nothing
if the value is private.
withPublicAccess (public 13) -- Just 13
withPublicAccess (private 13) -- Nothing
withPrivateAccess : AccessControlled a -> a
Get the value with private access level. Will always return the value.
withPrivateAccess (public 13) -- 13
withPrivateAccess (private 13) -- 13
withAccess : Access -> AccessControlled a -> Maybe a
Get the value with public or private access level. Will return Nothing
if the value is private and accessed using
public access.
withAccess Public (public 13) -- Just 13
withAccess Public (private 13) -- Nothing
withAccess Private (public 13) -- 13
withAccess Private (private 13) -- 13
map : (a -> b) -> AccessControlled a -> AccessControlled b
Apply a function to the access controlled value but keep the access unchanged.