iso-deriving-0.0.6: Deriving via arbitrary isomorphisms.

Safe HaskellNone
LanguageHaskell2010

Iso.Deriving

Synopsis

Documentation

newtype As a b Source #

As a b is represented at runtime as b, but we know we can in fact convert it into an a with no loss of information. We can think of it has having a *dual representation* as either a or b.

type As1 :: k -> Type -> Type

Constructors

As b 
Instances
(Project a b, Eq a) => Eq (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

(==) :: As a b -> As a b -> Bool #

(/=) :: As a b -> As a b -> Bool #

(Isomorphic a b, Num a) => Num (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

(+) :: As a b -> As a b -> As a b #

(-) :: As a b -> As a b -> As a b #

(*) :: As a b -> As a b -> As a b #

negate :: As a b -> As a b #

abs :: As a b -> As a b #

signum :: As a b -> As a b #

fromInteger :: Integer -> As a b #

(Project a b, Ord a) => Ord (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

compare :: As a b -> As a b -> Ordering #

(<) :: As a b -> As a b -> Bool #

(<=) :: As a b -> As a b -> Bool #

(>) :: As a b -> As a b -> Bool #

(>=) :: As a b -> As a b -> Bool #

max :: As a b -> As a b -> As a b #

min :: As a b -> As a b -> As a b #

(Isomorphic a b, Real a) => Real (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

toRational :: As a b -> Rational #

(Project a b, Show a) => Show (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

showsPrec :: Int -> As a b -> ShowS #

show :: As a b -> String #

showList :: [As a b] -> ShowS #

(Isomorphic a b, Semigroup a) => Semigroup (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

(<>) :: As a b -> As a b -> As a b #

sconcat :: NonEmpty (As a b) -> As a b #

stimes :: Integral b0 => b0 -> As a b -> As a b #

(Isomorphic a b, Monoid a) => Monoid (As a b) Source # 
Instance details

Defined in Iso.Deriving

Methods

mempty :: As a b #

mappend :: As a b -> As a b -> As a b #

mconcat :: [As a b] -> As a b #

newtype As1 f g a Source #

Like As for kind k -> Type.

type As1 :: k1 -> (k2 -> Type) -> k2 -> Type

Constructors

As1 

Fields

Instances
(forall x. Isomorphic (f x) (g x), Monad f) => Monad (As1 f g) Source # 
Instance details

Defined in Iso.Deriving

Methods

(>>=) :: As1 f g a -> (a -> As1 f g b) -> As1 f g b #

(>>) :: As1 f g a -> As1 f g b -> As1 f g b #

return :: a -> As1 f g a #

fail :: String -> As1 f g a #

(forall x. Isomorphic (f x) (g x), Functor f) => Functor (As1 f g) Source # 
Instance details

Defined in Iso.Deriving

Methods

fmap :: (a -> b) -> As1 f g a -> As1 f g b #

(<$) :: a -> As1 f g b -> As1 f g a #

(forall x. Isomorphic (f x) (g x), Applicative f) => Applicative (As1 f g) Source # 
Instance details

Defined in Iso.Deriving

Methods

pure :: a -> As1 f g a #

(<*>) :: As1 f g (a -> b) -> As1 f g a -> As1 f g b #

liftA2 :: (a -> b -> c) -> As1 f g a -> As1 f g b -> As1 f g c #

(*>) :: As1 f g a -> As1 f g b -> As1 f g b #

(<*) :: As1 f g a -> As1 f g b -> As1 f g a #

(forall x. Isomorphic (f x) (g x), Alternative f) => Alternative (As1 f g) Source # 
Instance details

Defined in Iso.Deriving

Methods

empty :: As1 f g a #

(<|>) :: As1 f g a -> As1 f g a -> As1 f g a #

some :: As1 f g a -> As1 f g [a] #

many :: As1 f g a -> As1 f g [a] #

newtype As2 f g a b Source #

Like As for kind k1 -> k2 -> Type.

type As2 :: k1 -> (k2 -> k3 -> Type) -> k2 -> k3 -> Type

Constructors

As2 (g a b) 
Instances
(forall (x :: k) (y :: k). Isomorphic (f x y) (g x y), Category f) => Category (As2 f g :: k -> k -> Type) Source # 
Instance details

Defined in Iso.Deriving

Methods

id :: As2 f g a a #

(.) :: As2 f g b c -> As2 f g a b -> As2 f g a c #

class Inject a b where Source #

Methods

inj :: a -> b Source #

class Project a b where Source #

Methods

prj :: b -> a Source #

class (Inject a b, Project a b) => Isomorphic a b where Source #

Laws: isom is an isomorphism, that is:

view isom . view (from isom) = id = view (from isom) . view isom

Minimal complete definition

Nothing

Methods

isom :: Iso' a b Source #