Add two new helper instances for Has
This commit is contained in:
parent
3b738e3aa3
commit
a735d3ffb6
|
@ -15,7 +15,6 @@
|
|||
{-# LANGUAGE PatternSynonyms #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE ViewPatterns #-}
|
||||
|
@ -72,9 +71,6 @@ newtype Reducer m a = Reducer
|
|||
MonadReader (Maybe FilePath, Scopes (Reducer m) NExprLoc),
|
||||
MonadState (HashMap FilePath NExprLoc))
|
||||
|
||||
instance Has (Maybe FilePath, Scopes m v) (Scopes m v) where
|
||||
hasLens f (x, y) = (x,) <$> f y
|
||||
|
||||
-- gatherNames :: NExprLoc -> HashSet VarName
|
||||
-- gatherNames = cata $ \case
|
||||
-- NSym_ _ var -> S.singleton var
|
||||
|
|
|
@ -108,6 +108,12 @@ class Has a b where
|
|||
instance Has a a where
|
||||
hasLens f = f
|
||||
|
||||
instance Has (a, b) a where
|
||||
hasLens f (x, y) = (, y) <$> f x
|
||||
|
||||
instance Has (a, b) b where
|
||||
hasLens f (x, y) = (x,) <$> f y
|
||||
|
||||
toEncodingSorted :: A.Value -> A.Encoding
|
||||
toEncodingSorted = \case
|
||||
A.Object m ->
|
||||
|
|
Loading…
Reference in a new issue