writeFile "CRITICOS.txt" (show ([head nodocritico]))
but in the file shows it to me so ["C"]
and I want to put it so [C]
as I could remove the double quotes?
writeFile "CRITICOS.txt" (show ([head nodocritico]))
but in the file shows it to me so ["C"]
and I want to put it so [C]
as I could remove the double quotes?
Instance show
for [a]
is based on the definition of show
for a
and Show String
always puts double quotes around String
.
You can omit the double quotes by writing your own version of the function:
import Data.List
myShow :: [String] -> String
myShow strs = concat [ "[", intercalate "," strs, "]" ]
You can also reuse the instance Show [a]
using a newtype
wrapper to change the instance that ghc selects:
newtype NoDoblesComillas = NDC { getString :: String }
instance Show NoDoblesComillas where
show = getString -- usando el string directamente
myShow :: [String] -> String
myShow = show . fmap NDC