{-# LANGUAGE UndecidableInstances #-}
module Strongweak.Generic.Via where
import Strongweak.Generic.Weaken
import Strongweak.Generic.Strengthen
import Strongweak
import GHC.Generics
import Data.Kind
newtype GenericallySW s (w :: Type) = GenericallySW { forall s w. GenericallySW s w -> s
unGenericallySW :: s }
instance
( Generic s, Generic w
, GWeaken (Rep s) (Rep w)
) => Weaken (GenericallySW s w) where
type Weak (GenericallySW s w) = w
weaken :: GenericallySW s w -> Weak (GenericallySW s w)
weaken = forall s w.
(Generic s, Generic w, GWeaken (Rep s) (Rep w)) =>
s -> w
weakenGeneric forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s w. GenericallySW s w -> s
unGenericallySW
instance
( Generic s, Generic w
, GStrengthenD (Rep w) (Rep s)
, Weaken (GenericallySW s w)
) => Strengthen (GenericallySW s w) where
strengthen :: Weak (GenericallySW s w)
-> Validation (NonEmpty StrengthenFail) (GenericallySW s w)
strengthen = forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap forall s w. s -> GenericallySW s w
GenericallySW forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall w s.
(Generic w, Generic s, GStrengthenD (Rep w) (Rep s)) =>
w -> Validation (NonEmpty StrengthenFail) s
strengthenGeneric