Browse Source

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.
master
Denis Tereshkin 4 years ago
parent
commit
002d00ea44
  1. 14
      test/ArbitraryInstances.hs

14
test/ArbitraryInstances.hs

@ -1,20 +1,22 @@
{-# LANGUAGE OverloadedStrings, TypeSynonymInstances, FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}
module ArbitraryInstances ( module ArbitraryInstances (
) where ) 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.Broker.Protocol
import ATrade.Price as P import ATrade.Price as P
import ATrade.Types
import qualified Data.Text as T import qualified Data.Text as T
import ATrade.Broker.Protocol
import Data.Time.Clock
import Data.Time.Calendar import Data.Time.Calendar
import Data.Time.Clock
notTooBig :: (Num a, Ord a) => a -> Bool notTooBig :: (Num a, Ord a) => a -> Bool
notTooBig x = abs x < 100000000 notTooBig x = abs x < 100000000
@ -51,7 +53,7 @@ instance Arbitrary OrderPrice where
| v == 2 -> Limit <$> arbitrary `suchThat` notTooBig | v == 2 -> Limit <$> arbitrary `suchThat` notTooBig
| v == 3 -> Stop <$> arbitrary `suchThat` notTooBig <*> arbitrary `suchThat` notTooBig | v == 3 -> Stop <$> arbitrary `suchThat` notTooBig <*> arbitrary `suchThat` notTooBig
| v == 4 -> StopMarket <$> arbitrary `suchThat` notTooBig | v == 4 -> StopMarket <$> arbitrary `suchThat` notTooBig
| otherwise -> fail "Invalid case" | otherwise -> error "Invalid case"
instance Arbitrary Operation where instance Arbitrary Operation where
arbitrary = elements [Buy, Sell] arbitrary = elements [Buy, Sell]

Loading…
Cancel
Save