Skip to content

Commit

Permalink
update package list and add typeclass derivations
Browse files Browse the repository at this point in the history
  • Loading branch information
curranosaurus committed Oct 31, 2024
1 parent 5a41df0 commit af5b435
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ library:
dependencies:
- QuickCheck
- bytestring
- deepseq
- hashable
- mono-traversable
- refined
Expand Down
2 changes: 1 addition & 1 deletion src/Data/StringVariants/NonEmptyText/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Prelude
-- | Non Empty Text, requires the input is between 1 and @n@ chars and not just whitespace.
newtype NonEmptyText (n :: Nat) = NonEmptyText Text
deriving stock (Data, Generic, Show, Read, Lift)
deriving newtype (Eq, Ord, ToJSON, MonoFoldable, Hashable, Semigroup, NFData)
deriving newtype (Eq, Ord, ToJSON, MonoFoldable, Hashable, NFData)

type instance Element (NonEmptyText _n) = Char

Expand Down
9 changes: 7 additions & 2 deletions src/Data/StringVariants/NullableNonEmptyText.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
Expand Down Expand Up @@ -30,14 +31,18 @@ module Data.StringVariants.NullableNonEmptyText
)
where

import Control.DeepSeq (NFData)
import Control.Monad
import Data.Aeson
import Data.Aeson qualified as J
import Data.Aeson.Key qualified as J
import Data.Aeson.Types qualified as J
import Data.Data (Proxy (..))
import Data.Data (Data, Proxy (..))
import Data.Hashable (Hashable)
import Data.Maybe (fromMaybe)
import Data.MonoTraversable (MonoFoldable)
import Data.StringVariants.NonEmptyText
import Data.StringVariants.NonEmptyText.Internal (NonEmptyText (..))
import Data.StringVariants.Util
import Data.Text (Text)
import Data.Text qualified as T
Expand Down Expand Up @@ -81,7 +86,7 @@ import Prelude
-- Use 'nullableNonEmptyTextToMaybeNonEmptyText' to extract @Maybe (NonEmptyText n)@ from @NullableNonEmptyText n@.
newtype NullableNonEmptyText n = NullableNonEmptyText (Maybe (NonEmptyText n))
deriving stock (Data, Generic, Show, Read, Lift)
deriving newtype (Eq, Ord, MonoFoldable, Hashable)
deriving newtype (Eq, Ord, Hashable, NFData)

mkNullableNonEmptyText :: forall n. (KnownNat n, 1 <= n) => Text -> Maybe (NullableNonEmptyText n)
mkNullableNonEmptyText t
Expand Down
4 changes: 3 additions & 1 deletion string-variants.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: string-variants
version: 0.3.1.0
version: 0.3.0.1
synopsis: Constrained text newtypes
description: See README at <https://github.com/MercuryTechnologies/string-variants#readme>.
category: Data
Expand Down Expand Up @@ -79,6 +79,8 @@ library
, aeson >=2.0.0.0
, base >=4.16 && <5
, bytestring
, deepseq
, hashable
, mono-traversable
, refined
, string-conversions
Expand Down

0 comments on commit af5b435

Please sign in to comment.