Reputation: 885
I want to write a file consisting of a list of tuples, but appendFile
demands string inputs. I imagine I could just show
or quote the tuples to stringify them and read
them later; however, I'd like to just be able to save the list of n-tuples to skip the "show
now and read
later" part. Is there a Show a=>FilePath -> a -> IO ()
version of the appendFile
function?
Upvotes: 1
Views: 135
Reputation: 105925
A quick hoogle search reveals that there isn't a function with type Show a => FilePath -> a -> IO ()
. However, it's not really hard to write it yourself:
showAppendFile :: Show a => FilePath -> a -> IO ()
showAppendFile p x = appendFile p (show x)
Upvotes: 2