When using takeFileName I get a type error:
:t v
print v
:t takeFileName
takeFileName v
v :: FilePath
FilePath "/media/miguel/backup/backups"
takeFileName :: FilePath -> FilePath
Couldn't match type ‘Turtle.FilePath’ with ‘String’
Expected type: IHaskellSysIO.FilePath
Actual type: Turtle.FilePath
In the first argument of ‘takeFileName’, namely ‘v’
In the expression: takeFileName v
Is it because turtle's FilePath is different from prelude's FilePath ?
Turtle still uses system-filepath
which has a customized "FilePath" type you can find here. Many other Haskell libraries would use a filepath library which just defines FilePath
as a synonym for a String
(type FilePath = String). This is the case here with IHaskell
.
So yes both FilePath types mismatch. Note that you can easily convert Turtle.FilePath
into a String
using show
(because the type has a Show instance). You can also convert it into a Text
using fp
from the Turtle.Format module.
system-filepath
is actually deprecated. There is an issue about this. Please read: https://github.com/Gabriel439/Haskell-Turtle-Library/issues/54
Hope it helps.