mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-12 04:08:29 +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 Text.Blaze (ToMarkup)
|
||||
|
||||
newtype Slug = Slug { unSlug :: Text }
|
||||
newtype Slug = Slug Text
|
||||
deriving (Show, Read, Eq, Typeable, PersistField, ToMarkup, Ord, Hashable)
|
||||
instance PersistFieldSql Slug where
|
||||
sqlType = sqlType . liftM unSlug
|
||||
|
||||
unSlug :: Slug -> Text
|
||||
unSlug (Slug t) = t
|
||||
|
||||
mkSlug :: MonadThrow m => Text -> m Slug
|
||||
mkSlug t
|
||||
| length t < minLen = throwM $ InvalidSlugException t "Too short"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user