2{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7{-# LANGUAGE StandaloneDeriving #-}
15import Data.Functor.Compose (Compose (..))
16import Data.Functor.Identity (Identity (..))
18import Data.Time (Day (..), fromGregorian)
20import Test.QuickCheck (Arbitrary (..), Property, counterexample)
21import qualified Data.Map as Map
25type Compose3 f g h = Compose (Compose f g) h
26type Compose3' f g h = Compose f (Compose g h)
31 , fooTuple :: (String, Text, Int)
32 -- This definition causes an infinite loop in genericTo and genericFrom!
33 -- , fooMap :: Map.Map String Foo
34 , fooMap :: Map.Map String (Text,Int)
35 } deriving (Show, Typeable, Data)
40 } deriving (Show, Eq, Data, Typeable)
42data OneConstructor = OneConstructor
43 deriving (Show, Eq, Typeable, Data)
45data Product2 a b = Product2 a b
46 deriving (Show, Eq, Typeable, Data)
48data Product6 a b c d e f = Product6 a b c d e f
49 deriving (Show, Eq, Typeable, Data)
51data Sum4 a b c d = Alt1 a | Alt2 b | Alt3 c | Alt4 d
52 deriving (Show, Eq, Typeable, Data)
55 (=~) :: a -> a -> Bool
57newtype Approx a = Approx { fromApprox :: a }
58 deriving (Show, Data, Typeable, ApproxEq, Num)
60instance (ApproxEq a) => Eq (Approx a) where
61 Approx a == Approx b = a =~ b
63data Nullary = C1 | C2 | C3 deriving (Eq, Show)
65data SomeType a = Nullary
67 | Product String (Maybe Char) a
68 | Record { testOne :: Double
69 , testTwo :: Maybe Bool
70 , testThree :: Maybe a
75-- | This type requires IncoherentInstances for the instances of the type
76-- classes Data.Aeson.TH.LookupField and Data.Aeson.Types.FromJSON.FromRecord.
78-- The minimum known requirements for this type are:
79-- * Record type with at least two fields
80-- * One field type is either a type parameter or a type/data family
81-- * Another field type is a @Maybe@ of the above field type
82data IncoherentInstancesNeeded a = IncoherentInstancesNeeded
83 { incoherentInstancesNeededMaybeNot :: a
84 , incoherentInstancesNeededMaybeYes :: Maybe a
87-- Used for testing UntaggedValue SumEncoding
91 | BothTextInt Text Int
96 GADT :: { gadt :: String } -> GADT String
99deriving instance Data (GADT String)
100deriving instance Eq (GADT a)
101deriving instance Show (GADT a)
103deriving instance Generic Foo
104deriving instance Generic UFoo
105deriving instance Generic OneConstructor
106deriving instance Generic (Product2 a b)
107deriving instance Generic (Product6 a b c d e f)
108deriving instance Generic (Sum4 a b c d)
109deriving instance Generic (Approx a)
110deriving instance Generic Nullary
111deriving instance Generic (SomeType a)
112#if __GLASGOW_HASKELL__ >= 706
113deriving instance Generic1 SomeType
115deriving instance Generic EitherTextInt
117failure :: Show a => String -> String -> a -> Property
118failure func msg v = counterexample
119 (func ++ " failed: " ++ msg ++ ", " ++ show v) False
121newtype BCEDay = BCEDay Day
125zeroDay = fromGregorian 0 0 0
127instance Arbitrary BCEDay where
128 arbitrary = fmap (BCEDay . ModifiedJulianDay . (+ toModifiedJulianDay zeroDay)) arbitrary
130instance ToJSON BCEDay where
131 toJSON (BCEDay d) = toJSON d
132 toEncoding (BCEDay d) = toEncoding d
134instance FromJSON BCEDay where
135 parseJSON = fmap BCEDay . parseJSON
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list