title: Haskell get directories in directory
body: <p>How can I get a list of directories that are in a directory?</p>
  
  <p>I've come up with the below, but I'm hoping there is a more elegant way:</p>
  
  <pre><code>import System.Directory
  import qualified Filesystem.Path as FsP
  import Filesystem.Path.CurrentOS
  import Control.Monad
  
  getDirectories :: Prelude.FilePath -&gt; IO [Prelude.FilePath]
  getDirectories x = do
    listDirectory x
    &gt;&gt;= (return . fmap decodeString)
    &gt;&gt;= return . fmap (FsP.append (decodeString x))
    &gt;&gt;= (return . fmap encodeString)
    &gt;&gt;= filterM doesDirectoryExist
  </code></pre>