-- | used by @IHaskell convert@
convert :: [Argument] -> IO ()
convert args =
  case fromJustConvertSpec (toConvertSpec args) of
    ConvertSpec
      { convertToIpynb = Identity toIpynb
      , convertInput = Identity inputFile
      , convertOutput = Identity outputFile
      , convertLhsStyle = Identity lhsStyle
      , convertOverwriteFiles = force
      }
      | toIpynb -> do
          unless force (failIfExists outputFile)
          lhsToIpynb lhsStyle inputFile outputFile
      | otherwise -> do
          unless force (failIfExists outputFile)
          ipynbToLhs lhsStyle inputFile outputFile

-- | Call fail when the named file already exists.
convert :: [Argument] -> IO ()
convert args =
  case fromJustConvertSpec (toConvertSpec args) of
    ConvertSpec
      { convertToIpynb = Identity toIpynb
      , convertInput = Identity inputFile
      , convertOutput = Identity outputFile
      , convertLhsStyle = Identity lhsStyle
      , convertOverwriteFiles = force
      }
      | toIpynb -> do
          unless force (failIfExists outputFile)
          lhsToIpynb lhsStyle inputFile outputFile
      | otherwise -> do
          unless force (failIfExists outputFile)
          ipynbToLhs lhsStyle inputFile outputFile

-- | Call fail when the named file already exists.
convert args =
  case fromJustConvertSpec (toConvertSpec args) of
    ConvertSpec
      { convertToIpynb = Identity toIpynb
      , convertInput = Identity inputFile
      , convertOutput = Identity outputFile
      , convertLhsStyle = Identity lhsStyle
      , convertOverwriteFiles = force
      }
      | toIpynb -> do
          unless force (failIfExists outputFile)
          lhsToIpynb lhsStyle inputFile outputFile
      | otherwise -> do
          unless force (failIfExists outputFile)
          ipynbToLhs lhsStyle inputFile outputFile

-- | Call fail when the named file already exists.