diff options
author | Joey Hess <joeyh@joeyh.name> | 2019-06-06 12:53:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2019-06-06 12:53:24 -0400 |
commit | 258a7c5cd10728d4f6c8968aadb2941b82281f9f (patch) | |
tree | b59ccb282b3241239bfe5158e7735cdf07f32a89 /Types/ActionItem.hs | |
parent | 3893d84764cf652c25307b1b647ac86783c4e033 (diff) |
add Key to all ActionItem constructors
Diffstat (limited to 'Types/ActionItem.hs')
-rw-r--r-- | Types/ActionItem.hs | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/Types/ActionItem.hs b/Types/ActionItem.hs index bee7156088..dbcaf0982f 100644 --- a/Types/ActionItem.hs +++ b/Types/ActionItem.hs @@ -1,6 +1,6 @@ {- items that a command can act on - - - Copyright 2016 Joey Hess <id@joeyh.name> + - Copyright 2016-2019 Joey Hess <id@joeyh.name> - - Licensed under the GNU AGPL version 3 or higher. -} @@ -14,36 +14,45 @@ import Types.Transfer import Git.FilePath data ActionItem - = ActionItemAssociatedFile AssociatedFile - | ActionItemKey - | ActionItemBranchFilePath BranchFilePath + = ActionItemAssociatedFile AssociatedFile Key + | ActionItemKey Key + | ActionItemBranchFilePath BranchFilePath Key | ActionItemFailedTransfer Transfer TransferInfo class MkActionItem t where mkActionItem :: t -> ActionItem -instance MkActionItem AssociatedFile where - mkActionItem = ActionItemAssociatedFile +instance MkActionItem (AssociatedFile, Key) where + mkActionItem = uncurry ActionItemAssociatedFile + +instance MkActionItem (Key, AssociatedFile) where + mkActionItem = uncurry $ flip ActionItemAssociatedFile instance MkActionItem Key where - mkActionItem _ = ActionItemKey + mkActionItem = ActionItemKey -instance MkActionItem BranchFilePath where - mkActionItem = ActionItemBranchFilePath +instance MkActionItem (BranchFilePath, Key) where + mkActionItem = uncurry ActionItemBranchFilePath instance MkActionItem (Transfer, TransferInfo) where mkActionItem = uncurry ActionItemFailedTransfer -actionItemDesc :: ActionItem -> Key -> String -actionItemDesc (ActionItemAssociatedFile (AssociatedFile (Just f))) _ = f -actionItemDesc (ActionItemAssociatedFile (AssociatedFile Nothing)) k = serializeKey k -actionItemDesc ActionItemKey k = serializeKey k -actionItemDesc (ActionItemBranchFilePath bfp) _ = descBranchFilePath bfp -actionItemDesc (ActionItemFailedTransfer _ i) k = - actionItemDesc (ActionItemAssociatedFile (associatedFile i)) k +actionItemDesc :: ActionItem -> String +actionItemDesc (ActionItemAssociatedFile (AssociatedFile (Just f)) _) = f +actionItemDesc (ActionItemAssociatedFile (AssociatedFile Nothing) k) = serializeKey k +actionItemDesc (ActionItemKey k) = serializeKey k +actionItemDesc (ActionItemBranchFilePath bfp _) = descBranchFilePath bfp +actionItemDesc (ActionItemFailedTransfer t i) = actionItemDesc $ + ActionItemAssociatedFile (associatedFile i) (transferKey t) + +actionItemKey :: ActionItem -> Key +actionItemKey (ActionItemAssociatedFile _ k) = k +actionItemKey (ActionItemKey k) = k +actionItemKey (ActionItemBranchFilePath _ k) = k +actionItemKey (ActionItemFailedTransfer t _) = transferKey t actionItemWorkTreeFile :: ActionItem -> Maybe FilePath -actionItemWorkTreeFile (ActionItemAssociatedFile (AssociatedFile af)) = af +actionItemWorkTreeFile (ActionItemAssociatedFile (AssociatedFile af) _) = af actionItemWorkTreeFile _ = Nothing actionItemTransferDirection :: ActionItem -> Maybe Direction |