Skip to content

Instantly share code, notes, and snippets.

@mizunashi-mana
Created March 2, 2019 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizunashi-mana/ddd620d408210f2cb5946e660da545a1 to your computer and use it in GitHub Desktop.
Save mizunashi-mana/ddd620d408210f2cb5946e660da545a1 to your computer and use it in GitHub Desktop.
module TestSpace.NotSpaceAsciiString where
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Gen
import Data.Coerce
import Data.Char (isSpace)
newtype NotSpace = NotSpace Char
deriving (Eq, Ord, Show)
newtype NotSpaceString1 = NotSpaceString1 [NotSpace]
deriving (Eq, Ord, Show)
instance Arbitrary NotSpace where
arbitrary = do
c <- elements [c | c <- ['\0'..'\127'], not $ isSpace c]
pure $ NotSpace c
instance Arbitrary NotSpaceString1 where
arbitrary = do
c <- arbitrary
l <- arbitrary
pure $ NotSpaceString1 $ c : l
fromNotSpaceString1 :: NotSpaceString1 -> String
fromNotSpaceString1 = coerce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment