Skip to content

Commit 5fd9f09

Browse files
committed
Add instance Bifunctor GenEntry
1 parent 5a2d75e commit 5fd9f09

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Codec/Archive/Tar/Types.hs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module Codec.Archive.Tar.Types (
7676
unfoldEntriesM,
7777
) where
7878

79+
import Data.Bifunctor (Bifunctor, bimap)
7980
import Data.Int (Int64)
8081
import Data.List.NonEmpty (NonEmpty(..))
8182
import Data.Monoid (Monoid(..))
@@ -145,7 +146,18 @@ data GenEntry tarPath linkTarget = Entry {
145146
-- | The tar format the archive is using.
146147
entryFormat :: !Format
147148
}
148-
deriving (Eq, Show)
149+
deriving
150+
( Eq
151+
, Show
152+
, Functor -- ^ @since 0.6.4.0
153+
)
154+
155+
-- | @since 0.6.4.0
156+
instance Bifunctor GenEntry where
157+
bimap f g e = e
158+
{ entryTarPath = f (entryTarPath e)
159+
, entryContent = fmap g (entryContent e)
160+
}
149161

150162
-- | Monomorphic tar archive entry, ready for serialization / deserialization.
151163
--
@@ -178,7 +190,12 @@ data GenEntryContent linkTarget
178190
| NamedPipe
179191
| OtherEntryType {-# UNPACK #-} !TypeCode LBS.ByteString
180192
{-# UNPACK #-} !FileSize
181-
deriving (Eq, Ord, Show)
193+
deriving
194+
( Eq
195+
, Ord
196+
, Show
197+
, Functor -- ^ @since 0.6.4.0
198+
)
182199

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

0 commit comments

Comments
 (0)