Eventually-decentralized project hosting and management platform
Clone
HTTPS:
darcs clone https://vervis.peers.community/repos/WvWbo
SSH:
darcs clone USERNAME@vervis.peers.community:WvWbo
Tags
TODO
Ident.hs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | {- This file is part of Vervis.
-
- Written in 2016, 2022 by fr33domlover <fr33domlover@riseup.net>.
-
- ♡ Copying is an act of love. Please copy, reuse and share.
-
- The author(s) have dedicated all copyright and related and neighboring
- rights to this software to the public domain worldwide. This software is
- distributed without any warranty.
-
- You should have received a copy of the CC0 Public Domain Dedication along
- with this software. If not, see
- <http://creativecommons.org/publicdomain/zero/1.0/>.
-}
-- | Dedicated identifier name types for type safety. For use in routes, models
-- and handlers.
module Vervis.Model.Ident
( Username (..)
, username2text
, text2username
, ShrIdent (..)
, shr2text
, text2shr
, KyIdent (..)
, ky2text
, text2ky
, RlIdent (..)
, rl2text
, text2rl
, PrjIdent (..)
, prj2text
, text2prj
, RpIdent (..)
, rp2text
, text2rp
, WflIdent (..)
, wfl2text
, text2wfl
, FldIdent (..)
, fld2text
, text2fld
, EnmIdent (..)
, enm2text
, text2enm
)
where
import Data.CaseInsensitive (CI)
import Data.Text (Text)
import Database.Esqueleto (SqlString)
import Database.Persist.Class (PersistField)
import Database.Persist.Sql (PersistFieldSql)
import Web.PathPieces (PathPiece)
import qualified Data.CaseInsensitive as CI
import Database.Esqueleto.Local ()
import Database.Persist.Class.Local ()
import Database.Persist.Sql.Local ()
import Web.PathPieces.Local ()
newtype Username = Username { unUsername :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
username2text :: Username -> Text
username2text = CI.original . unUsername
text2username :: Text -> Username
text2username = Username . CI.mk
newtype ShrIdent = ShrIdent { unShrIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
shr2text :: ShrIdent -> Text
shr2text = CI.original . unShrIdent
text2shr :: Text -> ShrIdent
text2shr = ShrIdent . CI.mk
newtype KyIdent = KyIdent { unKyIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
ky2text :: KyIdent -> Text
ky2text = CI.original . unKyIdent
text2ky :: Text -> KyIdent
text2ky = KyIdent . CI.mk
newtype RlIdent = RlIdent { unRlIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
rl2text :: RlIdent -> Text
rl2text = CI.original . unRlIdent
text2rl :: Text -> RlIdent
text2rl = RlIdent . CI.mk
newtype PrjIdent = PrjIdent { unPrjIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
prj2text :: PrjIdent -> Text
prj2text = CI.original . unPrjIdent
text2prj :: Text -> PrjIdent
text2prj = PrjIdent . CI.mk
newtype RpIdent = RpIdent { unRpIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
rp2text :: RpIdent -> Text
rp2text = CI.original . unRpIdent
text2rp :: Text -> RpIdent
text2rp = RpIdent . CI.mk
newtype WflIdent = WflIdent { unWflIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
wfl2text :: WflIdent -> Text
wfl2text = CI.original . unWflIdent
text2wfl :: Text -> WflIdent
text2wfl = WflIdent . CI.mk
newtype FldIdent = FldIdent { unFldIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
fld2text :: FldIdent -> Text
fld2text = CI.original . unFldIdent
text2fld :: Text -> FldIdent
text2fld = FldIdent . CI.mk
newtype EnmIdent = EnmIdent { unEnmIdent :: CI Text }
deriving
(Eq, Ord, Show, Read, PersistField, PersistFieldSql, SqlString, PathPiece)
enm2text :: EnmIdent -> Text
enm2text = CI.original . unEnmIdent
text2enm :: Text -> EnmIdent
text2enm = EnmIdent . CI.mk
|