{-# OPTIONS -Wno-orphans #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK hide #-}
module Control.Functor.Linear.Internal.Instances
( Data (..),
)
where
import Control.Functor.Linear.Internal.Class
import qualified Data.Functor.Linear.Internal.Applicative as Data
import qualified Data.Functor.Linear.Internal.Functor as Data
newtype Data f a = Data (f a)
instance Functor f => Data.Functor (Data f) where
fmap :: forall a b. (a %1 -> b) -> Data f a %1 -> Data f b
fmap a %1 -> b
f (Data f a
x) = f b %1 -> Data f b
forall (f :: * -> *) a. f a -> Data f a
Data ((a %1 -> b) %1 -> f a %1 -> f b
forall (f :: * -> *) a b.
Functor f =>
(a %1 -> b) %1 -> f a %1 -> f b
fmap a %1 -> b
f f a
x)
instance Applicative f => Data.Applicative (Data f) where
pure :: forall a. a -> Data f a
pure a
x = f a -> Data f a
forall (f :: * -> *) a. f a -> Data f a
Data (a %1 -> f a
forall (f :: * -> *) a. Applicative f => a %1 -> f a
pure a
x)
Data f (a %1 -> b)
f <*> :: forall a b. Data f (a %1 -> b) %1 -> Data f a %1 -> Data f b
<*> Data f a
x = f b %1 -> Data f b
forall (f :: * -> *) a. f a -> Data f a
Data (f (a %1 -> b)
f f (a %1 -> b) %1 -> f a %1 -> f b
forall (f :: * -> *) a b.
Applicative f =>
f (a %1 -> b) %1 -> f a %1 -> f b
<*> f a
x)