1{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TypeFamilies #-}
5{-# OPTIONS_GHC -fno-warn-orphans #-}
7module DataFamilies.Instances where
9import Control.Applicative
11import Data.Aeson.Types (FromJSON(..))
12import DataFamilies.Types
13import Test.QuickCheck (Arbitrary(..), elements, oneof)
16instance (Arbitrary a) => Arbitrary (Approx a) where
17 arbitrary = Approx <$> arbitrary
19instance Arbitrary (Nullary Int) where
20 arbitrary = elements [C1, C2, C3]
22instance Arbitrary a => Arbitrary (SomeType c () a) where
23 arbitrary = oneof [ pure Nullary
25 , Product <$> arbitrary <*> arbitrary <*> arbitrary
26 , Record <$> arbitrary <*> arbitrary <*> arbitrary
29instance Arbitrary (GADT String) where
30 arbitrary = GADT <$> arbitrary
32deriveJSON defaultOptions 'C1
33deriveJSON defaultOptions 'Nullary
34deriveJSON defaultOptions 'Approx
36deriveToJSON defaultOptions 'GADT
37-- We must write the FromJSON instance head ourselves
38-- due to the refined GADT return type
39instance FromJSON (GADT String) where
40 parseJSON = $(mkParseJSON defaultOptions 'GADT)
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