Skip to content

Commit

Permalink
Add instance Bifunctor GenEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Nov 26, 2024
1 parent 5a2d75e commit 5fd9f09
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Codec/Archive/Tar/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module Codec.Archive.Tar.Types (
unfoldEntriesM,
) where

import Data.Bifunctor (Bifunctor, bimap)
import Data.Int (Int64)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Monoid (Monoid(..))
Expand Down Expand Up @@ -145,7 +146,18 @@ data GenEntry tarPath linkTarget = Entry {
-- | The tar format the archive is using.
entryFormat :: !Format
}
deriving (Eq, Show)
deriving
( Eq
, Show
, Functor -- ^ @since 0.6.4.0
)

-- | @since 0.6.4.0
instance Bifunctor GenEntry where
bimap f g e = e
{ entryTarPath = f (entryTarPath e)
, entryContent = fmap g (entryContent e)
}

-- | Monomorphic tar archive entry, ready for serialization / deserialization.
--
Expand Down Expand Up @@ -178,7 +190,12 @@ data GenEntryContent linkTarget
| NamedPipe
| OtherEntryType {-# UNPACK #-} !TypeCode LBS.ByteString
{-# UNPACK #-} !FileSize
deriving (Eq, Ord, Show)
deriving
( Eq
, Ord
, Show
, Functor -- ^ @since 0.6.4.0
)

-- | Monomorphic content of a tar archive entry,
-- ready for serialization / deserialization.
Expand Down

0 comments on commit 5fd9f09

Please sign in to comment.