Added Generics to functions and structs

This commit is contained in:
vegowotenks 2025-02-21 17:21:57 +01:00
parent ac0e697622
commit 21bec764db
5 changed files with 37 additions and 8 deletions

View file

@ -23,7 +23,7 @@ import qualified Data.List.NonEmpty as NonEmpty
import qualified System.Directory as IO
import Text.Parsec (sepBy1, ParsecT, anyChar, many, char, choice, notFollowedBy, oneOf, option)
import Text.Parsec (sepBy1, ParsecT, anyChar, many, char, choice, notFollowedBy, oneOf)
import qualified Text.Parsec as Parsec
import Path as Path ( Path, File, parseRelFile, Rel, parseRelDir, Dir, Abs, (</>), fromAbsFile, fromRelFile )
@ -36,7 +36,8 @@ import qualified Ubc.Parse.Syntax.Language as UbcLanguage
data Import = Import
{ file :: File.File
, alias :: String
, alias :: Maybe String
, list :: [String]
}
deriving stock (Show)
@ -71,9 +72,11 @@ parse = do
[path] -> parseFile path
fs@_ -> fail $ multipleFoundMessage relFile fs
importAs <- Parsec.parserTraced "alias" $ option (NonEmpty.last fragments) importAlias
importAs <- Parsec.optionMaybe importAlias
return $ Import importedFile importAs
importList <- UbcLanguage.parens $ UbcLanguage.commaSeparated UbcLanguage.identifier
return $ Import importedFile importAs importList
importAlias :: Monad m => ParsecT String u m String
importAlias = UbcLanguage.reserved "as"