{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
#if __GLASGOW_HASKELL__ >= 802
{-# LANGUAGE ScopedTypeVariables #-}
#endif
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.ProtoLens.Labels where
import GHC.OverloadedLabels (IsLabel (..))
#if __GLASGOW_HASKELL__ >= 802
import GHC.Prim (Proxy#, proxy#)
#endif
import Data.ProtoLens.Field (HasField(..))
instance (HasField s x a, p ~ (a -> f a), q ~ (s -> f s), Functor f,
a ~ b) => IsLabel x (p -> q) where
#if __GLASGOW_HASKELL__ >= 802
fromLabel :: p -> q
fromLabel = Proxy# x -> (b -> f b) -> s -> f s
forall s (x :: Symbol) a (f :: * -> *).
(HasField s x a, Functor f) =>
Proxy# x -> (a -> f a) -> s -> f s
forall (f :: * -> *).
Functor f =>
Proxy# x -> (b -> f b) -> s -> f s
fieldOf (Proxy# x
forall {k} (a :: k). Proxy# a
proxy# :: Proxy# x)
#else
fromLabel x = fieldOf x
#endif