1{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE TemplateHaskell #-}
4{-# LANGUAGE TypeFamilies #-}
5{-# OPTIONS_GHC -fno-warn-orphans #-}
7module DataFamilies.Instances () where
13import Data.Aeson.Types (FromJSON(..))
14import DataFamilies.Types
15import Test.QuickCheck (Arbitrary(..), elements, oneof)
17instance (Arbitrary a) => Arbitrary (Approx a) where
18 arbitrary = Approx <$> arbitrary
20instance Arbitrary (Nullary Int) where
21 arbitrary = elements [C1, C2, C3]
23instance Arbitrary a => Arbitrary (SomeType c () a) where
24 arbitrary = oneof [ pure Nullary
26 , Product <$> arbitrary <*> arbitrary <*> arbitrary
27 , Record <$> arbitrary <*> arbitrary <*> arbitrary
31instance Arbitrary (GADT String) where
32 arbitrary = GADT <$> arbitrary
34deriveJSON defaultOptions 'C1
35deriveJSON defaultOptions 'Nullary
36deriveJSON defaultOptions 'Approx
38deriveToJSON defaultOptions 'GADT
39-- We must write the FromJSON instance head ourselves
40-- due to the refined GADT return type
41instance FromJSON (GADT String) where
42 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