git.iko.soy/typeable/cabal2nix
on master help sign in
Accommodate aeson-0.11
baed1b5Michael Alan Dorman
distribution-nixpkgs/src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs+15
@@ -1,4 +1,6 @@
1{-# LANGUAGE RecordWildCards #-}
1{-# LANGUAGE RecordWildCards #-}
2+{-# LANGUAGE CPP #-}
3+{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE DeriveGeneric #-}
5{-# LANGUAGE DeriveGeneric #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -63,11 +65,24 @@ instance FromJSON Identifier where
63 parseJSON (String s) = pure (review ident (T.unpack s))
65 parseJSON (String s) = pure (review ident (T.unpack s))
64 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
66 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid Nix identifier")
65
67
68+-- aeson-0.11 introduces a general instance, so we just need a couple
69+-- of specific ones
70+#if MIN_VERSION_aeson(0,11,0)
71+instance (FromJSON v) => FromJSON (Map Identifier v) where
72+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
73+
74+instance (FromJSON v) => FromJSON (Map PackageName v) where
75+ parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
76+
77+parseKey :: (FromJSON k) => Text -> k
78+parseKey s = either error id (parseEither parseJSON (String s))
79+#else
66instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
80instance (Ord k, FromJSON k, FromJSON v) => FromJSON (Map k v) where
67 parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
81 parseJSON = fmap (Map.mapKeys parseKey) . parseJSON
68 where
82 where
69 parseKey :: FromJSON k => Text -> k
83 parseKey :: FromJSON k => Text -> k
70 parseKey s = either error id (parseEither parseJSON (String s))
84 parseKey s = either error id (parseEither parseJSON (String s))
85+#endif
71
86
72readConfiguration :: FilePath -> IO Configuration
87readConfiguration :: FilePath -> IO Configuration
73readConfiguration path =
88readConfiguration path =