mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-21 08:21:55 +01:00
Hide a record accessor
This commit is contained in:
parent
0bf235760b
commit
3f4e86e5fe
@ -17,11 +17,14 @@ import qualified System.Random.MWC as MWC
|
|||||||
import GHC.Prim (RealWorld)
|
import GHC.Prim (RealWorld)
|
||||||
import Text.Blaze (ToMarkup)
|
import Text.Blaze (ToMarkup)
|
||||||
|
|
||||||
newtype Slug = Slug { unSlug :: Text }
|
newtype Slug = Slug Text
|
||||||
deriving (Show, Read, Eq, Typeable, PersistField, ToMarkup, Ord, Hashable)
|
deriving (Show, Read, Eq, Typeable, PersistField, ToMarkup, Ord, Hashable)
|
||||||
instance PersistFieldSql Slug where
|
instance PersistFieldSql Slug where
|
||||||
sqlType = sqlType . liftM unSlug
|
sqlType = sqlType . liftM unSlug
|
||||||
|
|
||||||
|
unSlug :: Slug -> Text
|
||||||
|
unSlug (Slug t) = t
|
||||||
|
|
||||||
mkSlug :: MonadThrow m => Text -> m Slug
|
mkSlug :: MonadThrow m => Text -> m Slug
|
||||||
mkSlug t
|
mkSlug t
|
||||||
| length t < minLen = throwM $ InvalidSlugException t "Too short"
|
| length t < minLen = throwM $ InvalidSlugException t "Too short"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user