{-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Optics.HasField (field) where import GHC.Records.Compat (HasField (..)) import GHC.TypeLits (Symbol) import Optics.Core (Lens', lens) field :: forall (name :: Symbol) r a. HasField name r a => Lens' r a field :: Lens' r a field = (r -> a) -> (r -> a -> r) -> Lens' r a forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b lens ((a -> r, a) -> a forall a b. (a, b) -> b snd ((a -> r, a) -> a) -> (r -> (a -> r, a)) -> r -> a forall b c a. (b -> c) -> (a -> b) -> a -> c . r -> (a -> r, a) f) ((a -> r, a) -> a -> r forall a b. (a, b) -> a fst ((a -> r, a) -> a -> r) -> (r -> (a -> r, a)) -> r -> a -> r forall b c a. (b -> c) -> (a -> b) -> a -> c . r -> (a -> r, a) f) where f :: r -> (a -> r, a) f :: r -> (a -> r, a) f = forall k (x :: k) r a. HasField x r a => r -> (a -> r, a) forall r a. HasField name r a => r -> (a -> r, a) hasField @name