{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Hyper.Type.Functor
( F (..)
, _F
, W_F (..)
) where
import Control.Lens (iso, mapped)
import Hyper
import Hyper.Class.Monad (HMonad (..))
import Hyper.Internal.Prelude
newtype F f h = F (f (h :# F f))
deriving stock (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) (h :: AHyperType) x. Rep (F f h) x -> F f h
forall (f :: * -> *) (h :: AHyperType) x. F f h -> Rep (F f h) x
$cto :: forall (f :: * -> *) (h :: AHyperType) x. Rep (F f h) x -> F f h
$cfrom :: forall (f :: * -> *) (h :: AHyperType) x. F f h -> Rep (F f h) x
Generic)
_F ::
Iso
(F f0 # k0)
(F f1 # k1)
(f0 (k0 # F f0))
(f1 (k1 # F f1))
_F :: forall (f0 :: * -> *) (k0 :: HyperType) (f1 :: * -> *)
(k1 :: HyperType).
Iso (F f0 # k0) (F f1 # k1) (f0 (k0 # F f0)) (f1 (k1 # F f1))
_F = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(F f0 ('AHyperType k0 :# F f0)
x) -> f0 ('AHyperType k0 :# F f0)
x) forall (f :: * -> *) (h :: AHyperType). f (h :# F f) -> F f h
F
makeCommonInstances [''F]
makeHTraversableApplyAndBases ''F
instance Monad f => HMonad (F f) where
hjoin :: forall (p :: HyperType).
Recursively HFunctor p =>
(HCompose (F f) (F f) # p) -> F f # p
hjoin =
( forall (f0 :: * -> *) (k0 :: HyperType) (f1 :: * -> *)
(k1 :: HyperType).
Iso (F f0 # k0) (F f1 # k1) (f0 (k0 # F f0)) (f1 (k1 # F f1))
_F
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ ( forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
( forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ forall (p :: HyperType).
Recursively HFunctor p =>
(p # HCompose (F f) (F f)) -> p # F f
t forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall s a. s -> Getting a s a -> a
^. forall (a0 :: HyperType) (b0 :: HyperType) (h0 :: HyperType)
(a1 :: HyperType) (b1 :: HyperType) (h1 :: HyperType).
Iso
(HCompose a0 b0 # h0)
(HCompose a1 b1 # h1)
(a0 # HCompose b0 h0)
(a1 # HCompose b1 h1)
_HCompose)
)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall s a. s -> Getting a s a -> a
^. forall (a0 :: HyperType) (b0 :: HyperType) (h0 :: HyperType)
(a1 :: HyperType) (b1 :: HyperType) (h1 :: HyperType).
Iso
(HCompose a0 b0 # h0)
(HCompose a1 b1 # h1)
(a0 # HCompose b0 h0)
(a1 # HCompose b1 h1)
_HCompose forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f0 :: * -> *) (k0 :: HyperType) (f1 :: * -> *)
(k1 :: HyperType).
Iso (F f0 # k0) (F f1 # k1) (f0 (k0 # F f0)) (f1 (k1 # F f1))
_F)
)
)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall s a. s -> Getting a s a -> a
^. forall (a0 :: HyperType) (b0 :: HyperType) (h0 :: HyperType)
(a1 :: HyperType) (b1 :: HyperType) (h1 :: HyperType).
Iso
(HCompose a0 b0 # h0)
(HCompose a1 b1 # h1)
(a0 # HCompose b0 h0)
(a1 # HCompose b1 h1)
_HCompose)
where
t ::
forall p.
Recursively HFunctor p =>
p # HCompose (F f) (F f) ->
p # F f
t :: forall (p :: HyperType).
Recursively HFunctor p =>
(p # HCompose (F f) (F f)) -> p # F f
t =
forall (h :: HyperType) (p :: HyperType) (q :: HyperType).
HFunctor h =>
(forall (n :: HyperType). HWitness h n -> (p # n) -> q # n)
-> (h # p) -> h # q
hmap (forall {k} (t :: k). Proxy t
Proxy @(Recursively HFunctor) forall (h :: HyperType) (c :: HyperType -> Constraint)
(n :: HyperType) r.
(HNodes h, HNodesConstraint h c) =>
Proxy c -> (c n => r) -> HWitness h n -> r
#> forall (h :: HyperType) (p :: HyperType).
(HMonad h, Recursively HFunctor p) =>
(HCompose h h # p) -> h # p
hjoin)
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ forall (c :: HyperType -> Constraint) (h :: HyperType)
(proxy :: Constraint -> *).
Recursively c h =>
proxy (c h) -> Dict (c h, HNodesConstraint h (Recursively c))
recursively (forall {k} (t :: k). Proxy t
Proxy @(HFunctor p))
instance RNodes (F f)
instance c (F f) => Recursively c (F f)
instance Traversable f => RTraversable (F f)