mirror of
https://github.com/srid/ema.git
synced 2024-11-29 09:25:14 +03:00
slug: add aeson instances
This commit is contained in:
parent
735b182dc8
commit
ed782ef1a9
@ -3,7 +3,7 @@
|
||||
## Unreleased (0.2.0.0)
|
||||
|
||||
- `Ema.Slug`
|
||||
- Add `Ord`, `Generic` and `Data` instances to `Slug`
|
||||
- Add `Ord`, `Generic`, `Data` and Aeson instances to `Slug`
|
||||
- Unicode normalize slugs using NFC
|
||||
- TODO(doc) Add `decodeSlug` and `encodeSlug`
|
||||
- Add default implementation based on Enum for `staticRoute`
|
||||
|
@ -1,9 +1,11 @@
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
|
||||
module Ema.Route.Slug where
|
||||
|
||||
import Data.Aeson (FromJSON, ToJSON)
|
||||
import Data.Data (Data)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Normalize as UT
|
||||
@ -11,7 +13,7 @@ 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, Data, Generic)
|
||||
deriving (Eq, Show, Ord, Data, Generic, ToJSON, FromJSON)
|
||||
|
||||
-- | Decode an URL component into a `Slug` using `Network.URI.Encode`
|
||||
decodeSlug :: Text -> Slug
|
||||
|
Loading…
Reference in New Issue
Block a user