ruin- Pliable records

Safe HaskellNone



This modules makes it possible to declare that a type Has only its Fields. This can lead to better type error messages.

These classses should be instantiated as follows. Note that makeRecords does this automatically.

  data XY x y = MkXY {x::x,y::y} deriving Generic

  instance ClosedHas s XY => Has s XY where
    {-# INLINE extricate1 #-}
    extricate1 = closedExtricate1

  instance HasCase "x" XY   -- Just like usual Has instances.
  instance HasCase "y" XY

  instance Build XY where
    {-# INLINE build #-}
    build = genericBuild



type ClosedHas s t = HasIf (Elem s (FieldNames t)) s t Source #

Like Has s t, but gives a type error if s isn't in Fields t.

class HasCase s t where Source #

Exactly the same as Has, but ClosedHas delegates to this copy, so that Has can delegate parametrically to ClosedHas!

Associated Types

type FieldTypeCase s t :: * Source #


extricate1Case :: Label s -> t -> Eval (FieldType s t) Source #

extricate1Case :: (Generic t, GBox (IsABox (Rep t)) t, GenericHas (Rep t) s (FieldType s t)) => Label s -> t -> Eval (FieldType s t) Source #


KnownSymbol s => HasCase s (R fd) Source # 

Associated Types

type FieldTypeCase (s :: Symbol) (R fd) :: * Source #


extricate1Case :: Label s -> R fd -> Eval (FieldType s (R fd)) Source #

closedExtricate1 :: forall s t. ClosedHas s t => Label s -> t -> Eval (FieldType s t) Source #