1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Extract lens to the top level.

This commit is contained in:
Rob Rix 2019-09-20 17:33:10 -04:00
parent 52bc7e640e
commit 4bc5491a25
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -1,4 +1,4 @@
{-# LANGUAGE DeriveGeneric, DerivingVia #-}
{-# LANGUAGE DeriveGeneric, DerivingVia, RankNTypes #-}
module Source.Loc
( Loc(..)
, Span(Span)
@ -24,6 +24,12 @@ instance Hashable Loc
instance NFData Loc
instance HasSpan Loc where
span_ = lens span (\l s -> l { span = s }) where
lens get put afa s = fmap (put s) (afa (get s))
span_ = lens span (\l s -> l { span = s })
{-# INLINE span_ #-}
type Lens' s a = forall f . Functor f => (a -> f a) -> (s -> f s)
lens :: (s -> a) -> (s -> a -> s) -> Lens' s a
lens get put afa s = fmap (put s) (afa (get s))
{-# INLINE lens #-}