<div dir="ltr">I'm trying to get ls to work in ghci like it does in bash using variadiac arguments in Haskell. I'm stuck at the moment so I thought I'd send this to #haskell-cafe for some help. I'm not quite sure how to proceed.<br><br>See the main function for what I want the end result to look like. Here is the code:<br><br><br>{-# LANGUAGE FlexibleInstances #-}<br>{-# LANGUAGE OverloadedStrings #-}<br>-- | An example module.<br>module Example (main) where<br><br>import qualified Turtle as Turtle<br>import Control.Foldl<br>import Control.Monad.IO.Class<br><br>lsDirEx :: MonadIO io => io [Turtle.FilePath]<br>lsDirEx = do<br>  Turtle.fold (Turtle.ls "/home") list<br><br>class PrintAllType t where -- use PrintAllType from <a href="https://rosettacode.org/wiki/Variadic_function#Haskell">https://rosettacode.org/wiki/Variadic_function#Haskell</a><br>    process :: [Turtle.FilePath] -> t<br><br>-- instance MonadIO io => PrintAllType (io [Turtle.FilePath]) where<br>instance PrintAllType (IO [Turtle.FilePath]) where<br>  process [] = do -- ls received no args print current directory<br>    Turtle.pwd >>= \fp -> Turtle.fold (Turtle.ls fp) list<br>  process (filePath:[]) = do -- ls recieved one filePath<br>    liftIO $ Turtle.fold (Turtle.ls filePath) list<br>  process _ = error "multiple arguments not currently supported"<br><br>-- instance (Show a, PrintAllType r) => PrintAllType (a -> r) where<br>--     process args = \a -> process (args ++ [fmt a])<br>--       where fmt thing = _ $ Turtle.format Turtle.w thing<br><br>ls :: (PrintAllType t) => t<br>ls = process []<br><br>-- | An example function.<br>main :: IO ()<br>main = do<br>  ls -- lists current directory<br>  ls ("/home" :: String) -- lists /home directory<br><br><br><br>Thanks,<br><br>Cody<br><br></div>