From c04a774a89e5ca4ea77cf73934d5eca96e9c9ab7 Mon Sep 17 00:00:00 2001 From: Risto Stevcev Date: Sat, 8 Oct 2016 02:03:32 +0200 Subject: [PATCH 1/2] Rewrote null check to use mempty --- src/Data/String.purs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Data/String.purs b/src/Data/String.purs index b7d8213..3ff773b 100644 --- a/src/Data/String.purs +++ b/src/Data/String.purs @@ -36,6 +36,7 @@ module Data.String import Prelude import Data.Maybe (Maybe(..), isJust) +import Data.Monoid (mempty) import Data.String.Unsafe as U -- | Returns the character at the given index, if the index is within bounds. @@ -72,7 +73,7 @@ foreign import _toChar :: (forall a. a -> Maybe a) -- | Returns `true` if the given string is empty. null :: String -> Boolean -null s = length s == zero +null = eq mempty -- | Returns the first character and the rest of the string, -- | if the string is not empty. From ab78019ef5624d4cbc832a532b509c1c2df86e58 Mon Sep 17 00:00:00 2001 From: Risto Stevcev Date: Sat, 8 Oct 2016 13:43:01 +0200 Subject: [PATCH 2/2] Rewrote null to check the empty string --- src/Data/String.purs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Data/String.purs b/src/Data/String.purs index 3ff773b..4a56cb2 100644 --- a/src/Data/String.purs +++ b/src/Data/String.purs @@ -36,7 +36,6 @@ module Data.String import Prelude import Data.Maybe (Maybe(..), isJust) -import Data.Monoid (mempty) import Data.String.Unsafe as U -- | Returns the character at the given index, if the index is within bounds. @@ -73,7 +72,7 @@ foreign import _toChar :: (forall a. a -> Maybe a) -- | Returns `true` if the given string is empty. null :: String -> Boolean -null = eq mempty +null s = s == "" -- | Returns the first character and the rest of the string, -- | if the string is not empty.