Как преобразовать конкатенированный String
в черепаху FilePath
? Например, следующая программа пытается прочитать некоторые текстовые файлы, объединить их в новую и удалить старые. Это не похоже на работу, хотя расширение OverloadedStrings
включено:Преобразование струны в Turtle.FilePath
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Environment
import System.IO
import Control.Monad
import Turtle
import Turtle.Prelude
import qualified Control.Foldl as L
main :: IO()
main = do
params <- getArgs
let n = read $ params !! 0
k = read $ params !! 1
-- Some magic is done here
-- After a while, read generated .txt files and concatenate them
files <- fold (find (suffix ".txt") ".") L.list
let concat = cat $ fmap input files
output (show n ++ "-" ++ show k ++ ".txt") concat
-- Remove old .txt files
mapM_ rm files
Ошибка выброшен является:
Couldn't match expected type ‘Turtle.FilePath’
with actual type ‘[Char]’
In the first argument of ‘output’, namely
‘(show n ++ "-" ++ show k ++ ".txt")’
Переключение output "example.txt" concat
просто работать нормально. Не является String
просто псевдоним типа [Char]
?
'fromString' указан [здесь] (http://hackage.haskell.org/package/turtle-1.2.8/docs/ Turtle.html). – pdexter
Но вы, вероятно, должны использовать интерфейс 'Format' черепахи, найденный здесь (http://hackage.haskell.org/package/turtle-1.2.8/docs/Turtle-Format.html) – pdexter