Re:Use Haskell for shell scripting
by TazeTSchnitzel on Friday January 30, 2015 @06:02AM
(#8971454)
Are those types just aliases of String?
Re:Use Haskell for shell scripting
by throwaway283719 on Friday January 30, 2015 @07:09AM
(#8971632)
No. For example, a FilePath is (after resolving a few other type aliases)
data Root
= RootPosix
| RootWindowsVolume Char
| RootWindowsCurrentVolume
data FilePath = FilePath
{ pathRoot :: Maybe Root
, pathDirectories :: [String]
, pathBasename :: Maybe String
, pathExtensions :: [String]
}
Re:Use Haskell for shell scripting
by marcosdumay on Friday January 30, 2015 @06:36AM
(#8971547)
What do you mean by "alias"?
Path carries String-like information, it can even be easily converted to and from strings. Yet, it's a strong type that won't let you write something like 'path </> file_contents' (although, with overloaded strings, you can do 'path </> "file_name"').
UTCTime is not String-like.
For example, the pwd function returns a FilePath type rather than a String:
The datefile function is also typed: So this really does seem to structure the data passed between commands, instead of the "stringly typing" unix shells have historically been known for.