From 36aa4e445c23a201e044c9dc2183cb9fca73c5e8 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 21 Mar 2018 20:30:39 -0400 Subject: [PATCH] Guard clauses. --- src/Data/Abstract/Module.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Data/Abstract/Module.hs b/src/Data/Abstract/Module.hs index 47aefbdff..85d039996 100644 --- a/src/Data/Abstract/Module.hs +++ b/src/Data/Abstract/Module.hs @@ -23,9 +23,8 @@ moduleForBlob :: Maybe FilePath -- ^ The root directory relative to which the mo -> term -- ^ The @term@ representing the body of the module. -> Module term -- ^ A 'Module' named appropriate for the 'Blob', holding the @term@, and constructed relative to the root 'FilePath', if any. moduleForBlob rootDir blob term = Module (moduleName blob) (blobPath blob) term - where moduleName Blob{..} = let path = dropExtensions (maybe takeFileName makeRelative rootDir blobPath) - in toName $ case blobLanguage of - -- TODO: Need a better way to handle module registration and resolution - Just Go -> takeDirectory path -- Go allows defining modules across multiple files in the same directory. - _ -> path + where moduleName Blob{..} | Just Go <- blobLanguage = toName (takeDirectory (modulePath blobPath)) + | otherwise = toName (modulePath blobPath) + -- TODO: Need a better way to handle module registration and resolution toName str = qualifiedName (BC.pack <$> splitWhen (== pathSeparator) str) + modulePath = dropExtensions . maybe takeFileName makeRelative rootDir