git.iko.soy/typeable/cabal2nix
on master help sign in
OrphanInstances.hs: provide an IsString instance for Platform
7eca934Peter Simons
distribution-nixpkgs/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs+7−3
@@ -76,10 +76,14 @@ instance IsString Dependency where
76instance IsString CompilerId where
76instance IsString CompilerId where
77 fromString = text2isString "CompilerId"
77 fromString = text2isString "CompilerId"
78
78
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+
79instance FromJSON Platform where
85instance FromJSON Platform where
80− parseJSON (String "i686-linux") = pure (Platform I386 Linux)
86+ parseJSON (String s) = pure (fromString (T.unpack s))
81− parseJSON (String "x86_64-linux") = pure (Platform X86_64 Linux)
82− parseJSON (String "x86_64-darwin") = pure (Platform X86_64 (OtherOS "darwin"))
83 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid platform")
87 parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid platform")
84
88
85instance FromJSON PackageName where
89instance FromJSON PackageName where