Package

purescript-gejang

Repository
justinwoo/purescript-gejang
License
MIT
Uploaded by
justinwoo
Published on
2019-08-22

This library is literally just a type class to extract a row type from a Record or Variant. You could also use TypeEquals instead.

How it works

class ExtractRow (record :: Type) (row :: # Type) | record -> row

instance extractRowRecord :: ExtractRow { | row } row
instance extractRowVariant :: ExtractRow (Variant row) row

Usage

type MyRecord =
  { apple :: String
  , banana :: String
  , kiwi :: SProxy "hi"
  }

extractionZone
  :: forall record r
   . ExtractRow record r
  => Proxy record -> RProxy r
extractionZone _ = RProxy

-- inferred type
myRow :: RProxy
  ( apple :: String
  , banana :: String
  , kiwi :: SProxy "hi"
  )
myRow = extractionZone (Proxy :: _ MyRecord)
Modules
Gejang
Dependencies