Grooming for the PermissionLevel module.
parent
9d3e139b52
commit
20b3a5aeb2
|
@ -1,10 +1,7 @@
|
||||||
-- | TODO: Phone module should include at least some sort of smart
|
|
||||||
-- | constructors, rejecting invalid phone numbers.
|
|
||||||
module App.PermissionLevel where
|
module App.PermissionLevel where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Codec.Argonaut (JsonCodec)
|
|
||||||
import Data.Codec.Argonaut as CA
|
import Data.Codec.Argonaut as CA
|
||||||
import Data.Codec.Argonaut.Variant as CAV
|
import Data.Codec.Argonaut.Variant as CAV
|
||||||
import Data.Variant as V
|
import Data.Variant as V
|
||||||
|
@ -23,10 +20,10 @@ codec =
|
||||||
dimap toVariant fromVariant $ CAV.variantMatch { permission: Right CA.string }
|
dimap toVariant fromVariant $ CAV.variantMatch { permission: Right CA.string }
|
||||||
where
|
where
|
||||||
toVariant = case _ of
|
toVariant = case _ of
|
||||||
None → V.inj (Proxy ∷ _ "permission") "none"
|
None → V.inj (Proxy ∷ _ "permission") "none"
|
||||||
Read → V.inj (Proxy ∷ _ "permission") "read"
|
Read → V.inj (Proxy ∷ _ "permission") "read"
|
||||||
Edit → V.inj (Proxy ∷ _ "permission") "edit"
|
Edit → V.inj (Proxy ∷ _ "permission") "edit"
|
||||||
Admin → V.inj (Proxy ∷ _ "permission") "admin"
|
Admin → V.inj (Proxy ∷ _ "permission") "admin"
|
||||||
|
|
||||||
fromVariant = V.match
|
fromVariant = V.match
|
||||||
{ permission:
|
{ permission:
|
||||||
|
|
Loading…
Reference in New Issue