Module

TsBridge.Core

Package
purescript-ts-bridge
Repository
thought2/purescript-ts-bridge

#RecordDef Source

class RecordDef :: Type -> Row Type -> Constraintclass RecordDef tok r  where

Members

Instances

#RecordDefRL Source

class RecordDefRL :: Type -> Row Type -> RowList Type -> Constraintclass RecordDefRL tok r rl  where

Members

Instances

#TsBridgeBy Source

class TsBridgeBy tok a  where

Type Class that is used by the type generator to recursively traverse types. Instances for the specific types will be defined on the user's side with a typeclass like this:

class TsBridge a where
  tsBridge :: a -> StandaloneTsType

Then the internal type class is forwarded to the one of the user. For this you need to define a token data type and an instance like this:

data Tok = Tok

instance TsBridge a => TsBridgeBy Tok a where
  tsBridgeBy _ = tsBridge

The token will then be passed to all generic functions of the library.

Members

#tsOpaqueType Source

tsOpaqueType :: forall tok a. TsBridgeBy tok a => tok -> Proxy a -> TsBridgeM (Array TsDeclaration)

For rare cases where you want to manually export an opaque type. Once you export a value that contains a reference to this type, the type will be generated and exported automatically. Thus in most cases you don't need this.

#tsTypeAlias Source

tsTypeAlias :: forall tok a. TsBridgeBy tok a => tok -> String -> Proxy a -> TsBridgeM (Array TsDeclaration)

For rare cases where you want to export a type alias. References to this type alias will be fully resolved in the generated code. So it is more practical to use a newtype instead, which can be references by name.

#tsTypeAliasFromValue Source

tsTypeAliasFromValue :: forall tok a. TsBridgeBy tok a => tok -> String -> a -> TsBridgeM (Array TsDeclaration)

#tsTypeAliasesFromValues Source

tsTypeAliasesFromValues :: forall tok r. RecordDef tok r => tok -> Record r -> TsBridgeM (Array TsDeclaration)

#tsValue Source

tsValue :: forall tok a. TsBridgeBy tok a => tok -> String -> a -> TsBridgeM (Array TsDeclaration)

Exports a single PureScript value to TypeScript. tsValues may be better choice.

#tsValues Source

tsValues :: forall tok r. RecordDef tok r => tok -> Record r -> TsBridgeM (Array TsDeclaration)