Commit 3fd1dd84281c984ada8dc10d860ac5e5961189dc Parent: 5d883de62ade297d0dfcc4d4e7f059b02e0ccfa5 Author: mcol <mcol@posteo.net> Date: 2022-05-28 21:28:55 +0100 Committer: mcol <mcol@posteo.net> Committed: 2022-05-28 21:28:55 +0100 polymorphise ToGVal instances
src/Types.hs Modified
@@ -257,8 +257,8 @@ GVal implementations for data definitions above, allowing commits to be rendered in Ginger templates. -} -instance ToGVal RunRepo TreeFile where - toGVal :: TreeFile -> GVal RunRepo +instance ToGVal m TreeFile where + toGVal :: TreeFile -> GVal m toGVal treefile = def { asHtml = html . treeFilePath $ treefile @@ -267,8 +267,8 @@ , asBoolean = True -- Used for conditionally checking readme/license template variables. } -instance ToGVal RunRepo TreeFileContents where - toGVal :: TreeFileContents -> GVal RunRepo +instance ToGVal m TreeFileContents where + toGVal :: TreeFileContents -> GVal m toGVal BinaryContents = def toGVal (FileContents bytestring) = toGVal bytestring toGVal (FolderContents treeFiles) = @@ -278,7 +278,7 @@ , asList = Just . fmap toGVal $ treeFiles } -treeAsLookup :: TreeFile -> Text -> Maybe (GVal RunRepo) +treeAsLookup :: TreeFile -> Text -> Maybe (GVal m) treeAsLookup treefile = \case "path" -> Just . toGVal . treeFilePath $ treefile "name" -> Just . toGVal . FP.takeFileName . T.unpack . treeFilePath $ treefile @@ -341,8 +341,8 @@ , refCommit :: Commit } -instance ToGVal RunRepo Ref where - toGVal :: Ref -> GVal RunRepo +instance ToGVal m Ref where + toGVal :: Ref -> GVal m toGVal ref = def { asHtml = html . refName $ ref @@ -350,7 +350,7 @@ , asLookup = Just . refAsLookup $ ref } -refAsLookup :: Ref -> Text -> Maybe (GVal RunRepo) +refAsLookup :: Ref -> Text -> Maybe (GVal m) refAsLookup ref = \case "name" -> Just . toGVal . refName $ ref "commit" -> Just . toGVal . refCommit $ ref