Created
March 2, 2019 11:54
-
-
Save mizunashi-mana/ddd620d408210f2cb5946e660da545a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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