From 002d00ea44ffe036e0a8060434d9a38f0243442c Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Fri, 9 Jul 2021 10:48:45 +0700 Subject: [PATCH] bugfix(build): use error instead of fail in Arbitrary OrderPrice instance fail is now a part of MonadFail class, and Arbitrary is not MonadFail, so I have to use `error` here. --- test/ArbitraryInstances.hs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/ArbitraryInstances.hs b/test/ArbitraryInstances.hs index 932230b..5a4fc6a 100644 --- a/test/ArbitraryInstances.hs +++ b/test/ArbitraryInstances.hs @@ -1,20 +1,22 @@ -{-# LANGUAGE OverloadedStrings, TypeSynonymInstances, FlexibleInstances #-} -{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeSynonymInstances #-} module ArbitraryInstances ( ) where -import Test.Tasty.QuickCheck as QC -import Test.QuickCheck.Instances () +import Test.QuickCheck.Instances () +import Test.Tasty.QuickCheck as QC -import ATrade.Types -import ATrade.Price as P -import qualified Data.Text as T -import ATrade.Broker.Protocol +import ATrade.Broker.Protocol +import ATrade.Price as P +import ATrade.Types +import qualified Data.Text as T -import Data.Time.Clock -import Data.Time.Calendar +import Data.Time.Calendar +import Data.Time.Clock notTooBig :: (Num a, Ord a) => a -> Bool notTooBig x = abs x < 100000000 @@ -51,7 +53,7 @@ instance Arbitrary OrderPrice where | v == 2 -> Limit <$> arbitrary `suchThat` notTooBig | v == 3 -> Stop <$> arbitrary `suchThat` notTooBig <*> arbitrary `suchThat` notTooBig | v == 4 -> StopMarket <$> arbitrary `suchThat` notTooBig - | otherwise -> fail "Invalid case" + | otherwise -> error "Invalid case" instance Arbitrary Operation where arbitrary = elements [Buy, Sell] @@ -132,4 +134,4 @@ instance Arbitrary Bar where instance Arbitrary BarTimeframe where arbitrary = BarTimeframe <$> (arbitrary `suchThat` (\p -> p > 0 && p < 86400 * 365)) - +