fromEditor :: PackageDescriptionEd -> PackageDescription
fromEditor (PDE pd exes'
        tests'
        benchmarks'
        mbLib' buildInfos) =
    let     exes = map (\ (Executable' s fb bii) -> if bii + 1 > length buildInfos
                                        then Executable (T.unpack s) fb (buildInfos !! (length buildInfos - 1))
                                        else Executable (T.unpack s) fb (buildInfos !! bii)) exes'
            tests = map (\ (Test' s fb bii) -> if bii + 1 > length buildInfos
                                        then TestSuite (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else TestSuite (T.unpack s) fb (buildInfos !! bii) False) tests'
            bms = map (\ (Benchmark' s fb bii) -> if bii + 1 > length buildInfos
                                        then Benchmark (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else Benchmark (T.unpack s) fb (buildInfos !! bii) False) benchmarks'
            mbLib = case mbLib' of
                    Nothing -> Nothing
#if MIN_VERSION_Cabal(1,22,0)
                    Just (Library' mn rmn rs es b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn rmn rs es b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn rmn rs es b (buildInfos !! bii))
#else
                    Just (Library' mn b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn b (buildInfos !! bii))
#endif
    in pd {
        library = mbLib
      , executables = exes
      , testSuites = tests
      , benchmarks = bms
      }
fromEditor :: PackageDescriptionEd -> PackageDescription
fromEditor (PDE pd exes'
        tests'
        benchmarks'
        mbLib' buildInfos) =
    let     exes = map (\ (Executable' s fb bii) -> if bii + 1 > length buildInfos
                                        then Executable (T.unpack s) fb (buildInfos !! (length buildInfos - 1))
                                        else Executable (T.unpack s) fb (buildInfos !! bii)) exes'
            tests = map (\ (Test' s fb bii) -> if bii + 1 > length buildInfos
                                        then TestSuite (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else TestSuite (T.unpack s) fb (buildInfos !! bii) False) tests'
            bms = map (\ (Benchmark' s fb bii) -> if bii + 1 > length buildInfos
                                        then Benchmark (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else Benchmark (T.unpack s) fb (buildInfos !! bii) False) benchmarks'
            mbLib = case mbLib' of
                    Nothing -> Nothing
#if MIN_VERSION_Cabal(1,22,0)
                    Just (Library' mn rmn rs es b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn rmn rs es b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn rmn rs es b (buildInfos !! bii))
#else
                    Just (Library' mn b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn b (buildInfos !! bii))
#endif
    in pd {
        library = mbLib
      , executables = exes
      , testSuites = tests
      , benchmarks = bms
      }
fromEditor (PDE pd exes'
        tests'
        benchmarks'
        mbLib' buildInfos) =
    let     exes = map (\ (Executable' s fb bii) -> if bii + 1 > length buildInfos
                                        then Executable (T.unpack s) fb (buildInfos !! (length buildInfos - 1))
                                        else Executable (T.unpack s) fb (buildInfos !! bii)) exes'
            tests = map (\ (Test' s fb bii) -> if bii + 1 > length buildInfos
                                        then TestSuite (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else TestSuite (T.unpack s) fb (buildInfos !! bii) False) tests'
            bms = map (\ (Benchmark' s fb bii) -> if bii + 1 > length buildInfos
                                        then Benchmark (T.unpack s) fb (buildInfos !! (length buildInfos - 1)) False
                                        else Benchmark (T.unpack s) fb (buildInfos !! bii) False) benchmarks'
            mbLib = case mbLib' of
                    Nothing -> Nothing
#if MIN_VERSION_Cabal(1,22,0)
                    Just (Library' mn rmn rs es b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn rmn rs es b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn rmn rs es b (buildInfos !! bii))
#else
                    Just (Library' mn b bii) -> if bii + 1 > length buildInfos
                                        then Just (Library mn b (buildInfos !! (length buildInfos - 1)))
                                        else Just (Library mn b (buildInfos !! bii))
#endif
    in pd {
        library = mbLib
      , executables = exes
      , testSuites = tests
      , benchmarks = bms
      }