writeBuildPlanCsv :: FilePath -> BuildPlan -> IO ()
writeBuildPlanCsv fp bp =
    -- Obviously a proper CSV library should be used... but we're minimizing
    -- deps
    System.IO.UTF8.writeFile fp $ unlines' $ map toRow $ Map.toList fullMap
  where
    -- Hackage server is buggy, and won't accept trailing newlines. See:
    -- https://github.com/haskell/hackage-server/issues/141#issuecomment-34615935
    unlines' = intercalate "\n"

    fullMap = Map.unions
        [ fmap spiVersion $ bpPackages bp
        , Map.mapMaybe id $ bpCore bp
        , bpOptionalCore bp
        ]

    toRow (PackageName name, version) = concat
        [ "\""
        , name
        , "\",\""
        , display version
        , "\",\"http://www.stackage.org/package/"
        , name
        , "\""
        ]
writeBuildPlanCsv :: FilePath -> BuildPlan -> IO ()
writeBuildPlanCsv fp bp =
    -- Obviously a proper CSV library should be used... but we're minimizing
    -- deps
    System.IO.UTF8.writeFile fp $ unlines' $ map toRow $ Map.toList fullMap
  where
    -- Hackage server is buggy, and won't accept trailing newlines. See:
    -- https://github.com/haskell/hackage-server/issues/141#issuecomment-34615935
    unlines' = intercalate "\n"

    fullMap = Map.unions
        [ fmap spiVersion $ bpPackages bp
        , Map.mapMaybe id $ bpCore bp
        , bpOptionalCore bp
        ]

    toRow (PackageName name, version) = concat
        [ "\""
        , name
        , "\",\""
        , display version
        , "\",\"http://www.stackage.org/package/"
        , name
        , "\""
        ]
writeBuildPlanCsv fp bp =
    -- Obviously a proper CSV library should be used... but we're minimizing
    -- deps
    System.IO.UTF8.writeFile fp $ unlines' $ map toRow $ Map.toList fullMap
  where
    -- Hackage server is buggy, and won't accept trailing newlines. See:
    -- https://github.com/haskell/hackage-server/issues/141#issuecomment-34615935
    unlines' = intercalate "\n"

    fullMap = Map.unions
        [ fmap spiVersion $ bpPackages bp
        , Map.mapMaybe id $ bpCore bp
        , bpOptionalCore bp
        ]

    toRow (PackageName name, version) = concat
        [ "\""
        , name
        , "\",\""
        , display version
        , "\",\"http://www.stackage.org/package/"
        , name
        , "\""
        ]