Module

Foreign.Class

Package
purescript-foreign-generic
Repository
paf31/purescript-foreign-generic

#Decode Source

class Decode a  where

The Decode class is used to generate decoding functions of the form Foreign -> F a using generics-rep deriving.

First, derive Generic for your data:

import Data.Generic.Rep

data MyType = MyType ...

derive instance genericMyType :: Generic MyType _

You can then use the genericDecode and genericDecodeJSON functions to decode your foreign/JSON-encoded data.

Members

Instances

#Encode Source

class Encode a  where

The Encode class is used to generate encoding functions of the form a -> Foreign using generics-rep deriving.

First, derive Generic for your data:

import Data.Generic.Rep

data MyType = MyType ...

derive instance genericMyType :: Generic MyType _

You can then use the genericEncode and genericEncodeJSON functions to encode your data as JSON.

Members

Instances