{-# OPTIONS_GHC -Wall #-}
module Leanpub.Concepts
(
ApiSecretKey (..)
, BookSlug (..)
, bookURL
, CouponCode (..)
, couponURL
, CouponMaxUses (..)
, CouponNote (..)
) where
import Numeric.Natural (Natural)
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.Lazy.Builder as TB
newtype ApiSecretKey = ApiSecretKey Text
newtype BookSlug = BookSlug Text
deriving Int -> BookSlug -> ShowS
[BookSlug] -> ShowS
BookSlug -> String
(Int -> BookSlug -> ShowS)
-> (BookSlug -> String) -> ([BookSlug] -> ShowS) -> Show BookSlug
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BookSlug] -> ShowS
$cshowList :: [BookSlug] -> ShowS
show :: BookSlug -> String
$cshow :: BookSlug -> String
showsPrec :: Int -> BookSlug -> ShowS
$cshowsPrec :: Int -> BookSlug -> ShowS
Show
bookURL :: BookSlug -> Text
bookURL :: BookSlug -> Text
bookURL (BookSlug Text
book) =
(Text -> Text
LT.toStrict (Text -> Text) -> (Builder -> Text) -> Builder -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText)
( String -> Builder
TB.fromString String
"https://leanpub.com/"
Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
TB.fromText Text
book
)
newtype CouponCode = CouponCode Text
deriving Int -> CouponCode -> ShowS
[CouponCode] -> ShowS
CouponCode -> String
(Int -> CouponCode -> ShowS)
-> (CouponCode -> String)
-> ([CouponCode] -> ShowS)
-> Show CouponCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CouponCode] -> ShowS
$cshowList :: [CouponCode] -> ShowS
show :: CouponCode -> String
$cshow :: CouponCode -> String
showsPrec :: Int -> CouponCode -> ShowS
$cshowsPrec :: Int -> CouponCode -> ShowS
Show
couponURL :: BookSlug -> CouponCode -> Text
couponURL :: BookSlug -> CouponCode -> Text
couponURL (BookSlug Text
book) (CouponCode Text
coupon) =
(Text -> Text
LT.toStrict (Text -> Text) -> (Builder -> Text) -> Builder -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Text
TB.toLazyText)
( String -> Builder
TB.fromString String
"https://leanpub.com/"
Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
TB.fromText Text
book
Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> String -> Builder
TB.fromString String
"/c/"
Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
TB.fromText Text
coupon
)
data CouponMaxUses
= CouponUseUnlimited
| CouponMaxUses Natural
deriving Int -> CouponMaxUses -> ShowS
[CouponMaxUses] -> ShowS
CouponMaxUses -> String
(Int -> CouponMaxUses -> ShowS)
-> (CouponMaxUses -> String)
-> ([CouponMaxUses] -> ShowS)
-> Show CouponMaxUses
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CouponMaxUses] -> ShowS
$cshowList :: [CouponMaxUses] -> ShowS
show :: CouponMaxUses -> String
$cshow :: CouponMaxUses -> String
showsPrec :: Int -> CouponMaxUses -> ShowS
$cshowsPrec :: Int -> CouponMaxUses -> ShowS
Show
data CouponNote = CouponNote Text
deriving Int -> CouponNote -> ShowS
[CouponNote] -> ShowS
CouponNote -> String
(Int -> CouponNote -> ShowS)
-> (CouponNote -> String)
-> ([CouponNote] -> ShowS)
-> Show CouponNote
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CouponNote] -> ShowS
$cshowList :: [CouponNote] -> ShowS
show :: CouponNote -> String
$cshow :: CouponNote -> String
showsPrec :: Int -> CouponNote -> ShowS
$cshowsPrec :: Int -> CouponNote -> ShowS
Show