TsBridge.Core
- Package
- purescript-ts-bridge
- Repository
- thought2/purescript-ts-bridge
#RecordDef Source
class RecordDef :: Type -> Row Type -> Constraint
class RecordDef tok r where
Members
recordDef :: { handleRow :: forall (a :: Type). TsBridgeBy tok a => tok -> String -> Proxy a -> TsBridgeM (Array TsDeclaration) } -> tok -> Record r -> TsBridgeM (Array TsDeclaration)
Instances
(RecordDefRL tok r rl, RowToList r rl) => RecordDef tok r
#RecordDefRL Source
class RecordDefRL :: Type -> Row Type -> RowList Type -> Constraint
class RecordDefRL tok r rl where
Members
recordDefRL :: { handleRow :: forall (a :: Type). TsBridgeBy tok a => tok -> String -> Proxy a -> TsBridgeM (Array TsDeclaration) } -> tok -> Record r -> Proxy rl -> TsBridgeM (Array TsDeclaration)
Instances
RecordDefRL tok r Nil
(RecordDefRL tok r rl, TsBridgeBy tok a, Cons sym a rx r, IsSymbol sym) => RecordDefRL tok r (Cons sym a rl)
#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
tsBridgeBy :: tok -> Proxy a -> TsBridgeM TsType
#tsModuleFile Source
tsModuleFile :: String -> Array (TsBridgeM (Array TsDeclaration)) -> Either AppError (Array TsModuleFile)
#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.
Useful for declaring multiple PureScript values to be used by TypeScript. Through record punning the risk of exporting them with wrong names can be eliminated.
tsValues Tok { foo, bar, baz }