iso-deriving-0.0.8: Deriving via arbitrary isomorphisms.

Safe HaskellNone
LanguageHaskell2010

Iso.Deriving

Synopsis

Documentation

type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t) Source #

type Iso' s a = Iso s s a a Source #

newtype As (a :: Type) 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 as having a dual representation as either a or b.

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 :: k1 -> Type) (g :: k1 -> Type) (a :: k1) Source #

Like As for kind k -> Type.

Constructors

As1 

Fields

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

Defined in Iso.Deriving

Methods

writer :: (a, s) -> As1 f g a #

tell :: s -> As1 f g () #

listen :: As1 f g a -> As1 f g (a, s) #

pass :: As1 f g (a, s -> s) -> As1 f g a #

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

Defined in Iso.Deriving

Methods

get :: As1 f g s #

put :: s -> As1 f g () #

state :: (s -> (a, s)) -> As1 f g a #

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

Defined in Iso.Deriving

Methods

ask :: As1 f g s #

local :: (s -> s) -> As1 f g a -> As1 f g a #

reader :: (s -> a) -> As1 f g a #

(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.

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 #

Class of isomorphic types.

Laws

right-inverse
inj . prj = id
left-inverse
prj . inj = id
compatibility
isom = dimap inj (fmap prj)

Minimal complete definition

Nothing

Methods

isom :: Iso' a b Source #