Skip to content

Commit

Permalink
Handle empty string case (#4116)
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Oct 17, 2021
1 parent d9f7c1d commit 7e42d6b
Showing 1 changed file with 11 additions and 11 deletions.
@@ -1,15 +1,14 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}

module Language.Marlowe.ACTUS.Definitions.ContractTerms where

import Control.Monad (mzero)
import Control.Monad (guard, mzero)
import Data.Aeson.TH (deriveJSON)
import Data.Aeson.Types (FromJSON, Options (..), Parser, ToJSON, Value (Null, Object, String), defaultOptions,
object, parseJSON, toJSON, (.:), (.=))
Expand Down Expand Up @@ -266,8 +265,9 @@ instance FromJSON Cycle where
<*> return False

unconsConstant :: Char -> Text -> Maybe Text
unconsConstant c t | T.head t == c = Just (T.tail t)
unconsConstant _ _ = Nothing
unconsConstant c t = do (ht, tt) <- uncons t
guard (ht == c)
return tt

hush :: Either a b -> Maybe b
hush = either (const Nothing) Just
Expand Down

0 comments on commit 7e42d6b

Please sign in to comment.