Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ToMarkup/ToValue instances for NonEmpty Char #64

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

- unreleased
* Add `ToMarkup` and `ToValue` instances for `NonEmpty Char`

- 0.8.2.8 (2021-03-04)
* Bump `base` upper bound to 4.16
* Bump `tasty` upper bound to 1.5
Expand Down
13 changes: 13 additions & 0 deletions src/Text/Blaze.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ import Data.Word (Word, Word32, Word64)
#if MIN_VERSION_base(4,8,0)
import Numeric.Natural (Natural)
#endif
#if MIN_VERSION_base(4,9,0)
import Data.List.NonEmpty (NonEmpty (..))
#endif

import Data.Text (Text)
import qualified Data.Text.Lazy as LT
Expand Down Expand Up @@ -280,3 +283,13 @@ instance ToValue Word32 where
instance ToValue Word64 where
toValue = stringValue . show
{-# INLINE toValue #-}

-- Non-empty strings
#if MIN_VERSION_base(4,9,0)
instance ToMarkup (NonEmpty Char) where
toMarkup (x :| xs) = string (x : xs)
preEscapedToMarkup (x :| xs) = preEscapedString (x : xs)

instance ToValue (NonEmpty Char) where
toValue (x :| xs) = stringValue (x : xs)
#endif