1
1
mirror of https://github.com/srid/ema.git synced 2024-11-25 20:12:20 +03:00

slug: derive Data and Generic

This commit is contained in:
Sridhar Ratnakumar 2021-05-13 22:34:45 -04:00
parent 560d074241
commit 735b182dc8
2 changed files with 5 additions and 2 deletions

View File

@ -3,7 +3,7 @@
## Unreleased (0.2.0.0)
- `Ema.Slug`
- Add `Ord` instance to `Slug`
- Add `Ord`, `Generic` and `Data` instances to `Slug`
- Unicode normalize slugs using NFC
- TODO(doc) Add `decodeSlug` and `encodeSlug`
- Add default implementation based on Enum for `staticRoute`

View File

@ -1,14 +1,17 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE InstanceSigs #-}
module Ema.Route.Slug where
import Data.Data (Data)
import qualified Data.Text as T
import qualified Data.Text.Normalize as UT
import qualified Network.URI.Encode as UE
-- | An URL path is made of multiple slugs, separated by '/'
newtype Slug = Slug {unSlug :: Text}
deriving (Eq, Show, Ord)
deriving (Eq, Show, Ord, Data, Generic)
-- | Decode an URL component into a `Slug` using `Network.URI.Encode`
decodeSlug :: Text -> Slug