git.iko.soy/typeable/cabal2nix
on master help sign in
OrphanInstances.hs: provide an IsString instance for Platform
commit7eca9349bec3654277bdebbec80e376092a875b9 authorPeter Simons <simons@cryp.to> dateTue 8 Sep 2015, 11:36 (11 years ago) parent036362a
1 file changed+7−3
distribution-nixpkgs/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+7−3
distribution-nixpkgs/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+7−3
@@ -76,10 +76,14 @@ instance IsString Dependency where
7676instance IsString CompilerId where
7777 fromString = text2isString "CompilerId"
7878
79+instance IsString Platform where
80+ fromString "i686-linux" = Platform I386 Linux
81+ fromString "x86_64-linux" = Platform X86_64 Linux
82+ fromString "x86_64-darwin" = Platform X86_64 (OtherOS "darwin")
83+ fromString s = error ("fromString: " ++ show s ++ " is not a valid platform")
84+
7985instance FromJSON Platform where
80− parseJSON (String "i686-linux") = pure (Platform I386 Linux)
81− parseJSON (String "x86_64-linux") = pure (Platform X86_64 Linux)
82− parseJSON (String "x86_64-darwin") = pure (Platform X86_64 (OtherOS "darwin"))
86+ parseJSON (String s) = pure (fromString (T.unpack s))
8387 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid platform")
8488
8589instance FromJSON PackageName where