From 2c107e71572888327496d327a36737c02f64d894 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 14 Mar 2024 06:54:00 +0100 Subject: chore: refactor `Comment.Language.fromPath` --- app/Comment/Language.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/Comment') diff --git a/app/Comment/Language.hs b/app/Comment/Language.hs index 7a9963f..3f8c7a4 100644 --- a/app/Comment/Language.hs +++ b/app/Comment/Language.hs @@ -25,9 +25,13 @@ newtype Language = Language {languageKey :: L.LanguageKey} deriving (Eq, Show, Generic) deriving newtype (Binary) -fromPath :: FilePath -> N.NonEmpty Language +-- TODO Support amiguous file languages +-- +-- @backlog +fromPath :: FilePath -> Language fromPath fp = - fromMaybe (throw $ E.UnknownFile fp) + N.head + . fromMaybe (throw $ E.UnknownFile fp) . N.nonEmpty . map (Language . L.languageName) $ L.languagesForPath fp -- cgit v1.2.3