strongweak-0.9.0: Convert between strong and weak representations of types
Safe HaskellNone
LanguageGHC2021

Strongweak.Weaken

Synopsis

Weaken class

class Weaken a where Source #

Weaken some a, relaxing certain invariants.

See Strongweak for class design notes and laws.

Associated Types

type Weak a Source #

The weakened type for some type.

Methods

weaken :: a -> Weak a Source #

Weaken some a to its associated weak type Weak a.

Instances

Instances details
Weaken Int16 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Int16 
Instance details

Defined in Strongweak.Weaken

Methods

weaken :: Int16 -> Weak Int16 Source #

Weaken Int32 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Int32 
Instance details

Defined in Strongweak.Weaken

Methods

weaken :: Int32 -> Weak Int32 Source #

Weaken Int64 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Int64 
Instance details

Defined in Strongweak.Weaken

Methods

weaken :: Int64 -> Weak Int64 Source #

Weaken Int8 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Int8 
Instance details

Defined in Strongweak.Weaken

Methods

weaken :: Int8 -> Weak Int8 Source #

Weaken Word16 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Word16 
Instance details

Defined in Strongweak.Weaken

Weaken Word32 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Word32 
Instance details

Defined in Strongweak.Weaken

Weaken Word64 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Word64 
Instance details

Defined in Strongweak.Weaken

Weaken Word8 Source # 
Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak Word8 
Instance details

Defined in Strongweak.Weaken

Methods

weaken :: Word8 -> Weak Word8 Source #

Weaken (Identity a) Source #

Strip wrapper.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Identity a) 
Instance details

Defined in Strongweak.Weaken

type Weak (Identity a) = a

Methods

weaken :: Identity a -> Weak (Identity a) Source #

Weaken (NonEmpty a) Source #

Weaken non-empty lists into plain lists.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (NonEmpty a) 
Instance details

Defined in Strongweak.Weaken

type Weak (NonEmpty a) = [a]

Methods

weaken :: NonEmpty a -> Weak (NonEmpty a) Source #

Weaken a => Weaken [a] Source #

Decomposer. Weaken every element in a list.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak [a] 
Instance details

Defined in Strongweak.Weaken

type Weak [a] = [Weak a]

Methods

weaken :: [a] -> Weak [a] Source #

(Weaken a, Weaken b) => Weaken (Either a b) Source #

Decomposer. Weaken either side of an Either.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Either a b) 
Instance details

Defined in Strongweak.Weaken

type Weak (Either a b) = Either (Weak a) (Weak b)

Methods

weaken :: Either a b -> Weak (Either a b) Source #

(Generic s, Generic w, GWeaken (Rep s) (Rep w)) => Weaken (GenericallySW s w) Source # 
Instance details

Defined in Strongweak.Generic

Associated Types

type Weak (GenericallySW s w) 
Instance details

Defined in Strongweak.Generic

type Weak (GenericallySW s w) = w
(Weaken a, Weaken b) => Weaken (a, b) Source #

Decomposer. Weaken both elements of a tuple.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (a, b) 
Instance details

Defined in Strongweak.Weaken

type Weak (a, b) = (Weak a, Weak b)

Methods

weaken :: (a, b) -> Weak (a, b) Source #

Weaken (Const a b) Source #

Strip wrapper.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Const a b) 
Instance details

Defined in Strongweak.Weaken

type Weak (Const a b) = a

Methods

weaken :: Const a b -> Weak (Const a b) Source #

Weaken (Refined p a) Source #

Strip refined type refinement.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Refined p a) 
Instance details

Defined in Strongweak.Weaken

type Weak (Refined p a) = a

Methods

weaken :: Refined p a -> Weak (Refined p a) Source #

Vector v a => Weaken (Vector v n a) Source #

Weaken sized vectors into plain lists.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Vector v n a) 
Instance details

Defined in Strongweak.Weaken

type Weak (Vector v n a) = [a]

Methods

weaken :: Vector v n a -> Weak (Vector v n a) Source #

Weaken (Refined1 p f a) Source #

Strip refined functor type refinement.

Instance details

Defined in Strongweak.Weaken

Associated Types

type Weak (Refined1 p f a) 
Instance details

Defined in Strongweak.Weaken

type Weak (Refined1 p f a) = f a

Methods

weaken :: Refined1 p f a -> Weak (Refined1 p f a) Source #

liftWeakF :: Weaken a => (Weak a -> b) -> a -> b Source #

Lift a function on a weak type to the associated strong type by weakening first.

Strength switch helper

data Strength Source #

Strength enumeration: is it strong, or weak?

Primarily interesting at the type level (using DataKinds).

Constructors

Strong 
Weak 

type family SW (s :: Strength) a where ... Source #

Get either the strong or weak representation of a type, depending on the type-level "switch" provided.

This is intended to be used in data types that take a Strength type. Define your type using strong fields wrapped in SW s. You then get the weak representation for free, using the same definition.

data A (s :: Strength) = A
  { a1 :: SW s Word8
  , a2 :: String }

Equations

SW 'Strong a = a 
SW 'Weak a = Weak a 

type family SWDepth (n :: Natural) a where ... Source #

Track multiple levels of weakening. Silly thought I had, don't think it's useful.

Equations

SWDepth 0 a = a 
SWDepth n a = Weak (SWDepth (n - 1) a)