1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define unLatest as a function rather than a field selector.

This commit is contained in:
Rob Rix 2018-05-11 09:05:27 -04:00
parent 46295fed52
commit f8966a11ed

View File

@ -55,9 +55,12 @@ instance Location (Located location) where
-- | A cell holding a single value. Writes will replace any prior value. -- | A cell holding a single value. Writes will replace any prior value.
-- This is isomorphic to 'Last' from Data.Monoid, but is more convenient -- This is isomorphic to 'Last' from Data.Monoid, but is more convenient
-- because it has a 'Reducer' instance. -- because it has a 'Reducer' instance.
newtype Latest value = Latest { unLatest :: Maybe value } newtype Latest value = Latest (Maybe value)
deriving (Eq, Foldable, Functor, Generic1, Lower, Ord, Show, Traversable) deriving (Eq, Foldable, Functor, Generic1, Lower, Ord, Show, Traversable)
unLatest :: Latest value -> Maybe value
unLatest (Latest value) = value
instance Semigroup (Latest value) where instance Semigroup (Latest value) where
a <> Latest Nothing = a a <> Latest Nothing = a
_ <> b = b _ <> b = b