@@ -1,4 +1,4 @@
1−{-# LANGUAGE ExistentialQuantification,DeriveGeneric,DeriveAnyClass,TypeSynonymInstances,FlexibleInstances,OverloadedStrings #-}
1+{-# LANGUAGE ExistentialQuantification,FlexibleInstances,OverloadedStrings #-}
22{-# OPTIONS_GHC -fno-warn-orphans #-}
33
44module ProjectM36.Arbitrary where
@@ -15,9 +15,8 @@ import Data.Time
1515import Control.Monad.Reader
1616
1717arbitrary' :: AtomType -> WithTCMap Gen (Either RelationalError Atom)
18−arbitrary' IntegerAtomType = do
19− i <- lift (arbitrary :: Gen Integer)
20− pure $ Right $ IntegerAtom i
18+arbitrary' IntegerAtomType =
19+ Right . IntegerAtom <$> lift (arbitrary :: Gen Integer)
2120
2221arbitrary' (RelationAtomType attrs) = do
2322 tcMap <-ask
@@ -26,33 +25,26 @@ arbitrary' (RelationAtomType attrs) = do
2625 Left err -> pure $ Left err
2726 Right rel -> pure $ Right $ RelationAtom rel
2827
29−arbitrary' IntAtomType = do
30− i <- lift (arbitrary :: Gen Int)
31− pure $ Right $ IntAtom i
28+arbitrary' IntAtomType =
29+ Right . IntAtom <$> lift (arbitrary :: Gen Int)
3230
33−arbitrary' DoubleAtomType = do
34− i <- lift (arbitrary :: Gen Double)
35− pure $ Right $ DoubleAtom i
31+arbitrary' DoubleAtomType =
32+ Right . DoubleAtom <$> lift (arbitrary :: Gen Double)
3633
37−arbitrary' TextAtomType = do
38− i <- lift (arbitrary :: Gen Text)
39− pure $ Right $ TextAtom i
34+arbitrary' TextAtomType =
35+ Right . TextAtom <$> lift (arbitrary :: Gen Text)
4036
41−arbitrary' DayAtomType = do
42− i <- lift (arbitrary :: Gen Day)
43− pure $ Right $ DayAtom i
37+arbitrary' DayAtomType =
38+ Right . DayAtom <$> lift (arbitrary :: Gen Day)
4439
45−arbitrary' DateTimeAtomType = do
46− i <- lift (arbitrary :: Gen UTCTime)
47− pure $ Right $ DateTimeAtom i
40+arbitrary' DateTimeAtomType =
41+ Right . DateTimeAtom <$> lift (arbitrary :: Gen UTCTime)
4842
49−arbitrary' ByteStringAtomType = do
50− bs <- lift (arbitrary :: Gen B.ByteString)
51− pure $ Right $ ByteStringAtom bs
43+arbitrary' ByteStringAtomType =
44+ Right . ByteStringAtom <$> lift (arbitrary :: Gen B.ByteString)
5245
53−arbitrary' BoolAtomType = do
54− i <- lift (arbitrary :: Gen Bool)
55− pure $ Right $ BoolAtom i
46+arbitrary' BoolAtomType =
47+ Right . BoolAtom <$> lift (arbitrary :: Gen Bool)
5648
5749arbitrary' (IntervalAtomType atomTy) = do
5850 tcMap <- ask
@@ -60,8 +52,8 @@ arbitrary' (IntervalAtomType atomTy) = do
6052 case eitherAtomType of
6153 Left err -> pure $ Left err
6254 Right atomType' -> do
63− a <- lift $ (arbitrary :: Gen Bool)
64− b <- lift $ (arbitrary :: Gen Bool)
55+ a <- lift (arbitrary :: Gen Bool)
56+ b <- lift (arbitrary :: Gen Bool)
6557 pure $ Right $ IntervalAtom atomType' atomType' a b
6658
6759arbitrary' constructedAtomType@(ConstructedAtomType tcName tvMap) = do
@@ -73,7 +65,7 @@ arbitrary' constructedAtomType@(ConstructedAtomType tcName tvMap) = do
7365 case eitherGenDCDef of
7466 Left err -> pure $ Left err
7567 Right genDCDef -> do
76− dcDef <- lift $ genDCDef
68+ dcDef <- lift genDCDef
7769 case resolvedAtomTypesForDataConstructorDefArgs tcMap tvMap dcDef of
7870 Left err -> pure $ Left err
7971 Right atomTypes -> do
@@ -104,7 +96,7 @@ instance Arbitrary B.ByteString where
10496arbitraryRelationTuple :: Attributes -> WithTCMap Gen (Either RelationalError RelationTuple)
10597arbitraryRelationTuple attris = do
10698 tcMap <- ask
107− listOfMaybeAType <- lift $ sequence $ map ((\aTy -> runReaderT (arbitrary' aTy) tcMap) . atomType) (V.toList attris)
99+ listOfMaybeAType <- lift $ mapM ((\aTy -> runReaderT (arbitrary' aTy) tcMap) . atomType) (V.toList attris)
108100 case sequence listOfMaybeAType of
109101 Left err -> pure $ Left err
110102 Right listOfAttr -> do