diff --git a/CHANGELOG.md b/CHANGELOG.md index 5750368..2b060e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/Ema/Route/Slug.hs b/src/Ema/Route/Slug.hs index 1c83750..cefbf22 100644 --- a/src/Ema/Route/Slug.hs +++ b/src/Ema/Route/Slug.hs @@ -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