TsBridge
- Package
- purescript-ts-bridge
- Repository
- thought2/purescript-ts-bridge
Re-exports from TsBridge.Class
#TsBridge Source
class TsBridge (a :: Type) where
Members
Instances
(TsBridge a, TsBridge b) => TsBridge (Either a b)
(TsBridge a, TsBridge b) => TsBridge (Tuple a b)
TsBridge Number
(TsBridgeRecord Tok r) => TsBridge (Record r)
(TsBridgeTsRecord Tok r) => TsBridge (TsRecord r)
(TsBridgeVariant Tok r) => TsBridge (Variant r)
TsBridge String
TsBridge Boolean
TsBridge Int
TsBridge Char
TsBridge Unit
(TsBridge a) => TsBridge (Array a)
(TsBridge a) => TsBridge (Object a)
(TsBridge a) => TsBridge (Effect a)
(TsBridge a) => TsBridge (Nullable a)
(TsBridge a, TsBridge b) => TsBridge (a -> b)
(TsBridge a, TsBridge b, TsBridge c) => TsBridge (Fn2 a b c)
(TsBridge a, TsBridge b, TsBridge c, TsBridge d) => TsBridge (Fn3 a b c d)
(TsBridge a, TsBridge b, TsBridge c, TsBridge d, TsBridge e) => TsBridge (Fn4 a b c d e)
(TsBridge a, TsBridge b) => TsBridge (EffectFn1 a b)
(TsBridge a, TsBridge b, TsBridge c) => TsBridge (EffectFn2 a b c)
(TsBridge a, TsBridge b, TsBridge c, TsBridge d) => TsBridge (EffectFn3 a b c d)
(TsBridge a, TsBridge b, TsBridge c, TsBridge d, TsBridge e) => TsBridge (EffectFn4 a b c d e)
(TsBridge a) => TsBridge (Maybe a)
(TsBridge a) => TsBridge (Promise a)
(IsSymbol sym) => TsBridge (TypeVar sym)
(TsBridge a, TsBridge b) => TsBridge (OneOf a b)
(TsBridge a, TsBridge b) => TsBridge (Intersection a b)
(TsBridgeVariantEncodedFlat Tok symTag r) => TsBridge (VariantEncodedFlat symTag r)
(TsBridgeVariantEncodedNested Tok symTag symVal r) => TsBridge (VariantEncodedNested symTag symVal r)
TsBridge Undefined
TsBridge Null
(NTupleList Tok as) => TsBridge (NTuple as)
(IsSymbol sym) => TsBridge (StringLit sym)
TsBridge (BooleanLit "true")
TsBridge (BooleanLit "false")
(Reflectable h String) => TsBridge (Lit h String)
(Reflectable h Boolean) => TsBridge (Lit h Boolean)
(Reflectable h Int) => TsBridge (Lit h Int)
Re-exports from TsBridge.Cli
Re-exports from TsBridge.Core
#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
#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.
#tsTypeAliasesFromValues Source
tsTypeAliasesFromValues :: forall tok r. RecordDef tok r => tok -> Record r -> TsBridgeM (Array TsDeclaration)
#tsTypeAliasFromValue Source
tsTypeAliasFromValue :: forall tok a. TsBridgeBy tok a => tok -> String -> a -> TsBridgeM (Array TsDeclaration)
#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.
#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.
#tsModuleFile Source
tsModuleFile :: String -> Array (TsBridgeM (Array TsDeclaration)) -> Either AppError (Array TsModuleFile)
Re-exports from TsBridge.DefaultImpls
#NTupleList Source
class NTupleList :: Type -> List' @Type Type -> Constraint
class NTupleList tok (xs :: List' Type) where
Members
tsBridgeNTupleList :: tok -> Proxy xs -> TsBridgeM (Array TsType)
Instances
NTupleList tok Nil'
(TsBridgeBy tok a, NTupleList tok as) => NTupleList tok (Cons' a as)
#TsBridgeRecord Source
class TsBridgeRecord :: Type -> Row Type -> Constraint
class TsBridgeRecord tok r where
Members
tsBridgeRecord :: tok -> Proxy (Record r) -> TsBridgeM TsType
tsBridge
type class method implementation for the Record typeSee this reference for details.
Instances
(RowToList r rl, TsBridgeRecordRL tok rl) => TsBridgeRecord tok r
#TsBridgeRecordRL Source
class TsBridgeRecordRL :: Type -> RowList Type -> Constraint
class TsBridgeRecordRL tok rl where
Members
tsBridgeRecordRL :: tok -> Proxy rl -> TsBridgeM (Array TsRecordField)
Instances
TsBridgeRecordRL tok Nil
(TsBridgeBy tok t, TsBridgeRecordRL tok rl, IsSymbol s) => TsBridgeRecordRL tok (Cons s t rl)
#TsBridgeVariant Source
class TsBridgeVariant :: Type -> Row Type -> Constraint
class TsBridgeVariant tok r where
Members
tsBridgeVariant :: tok -> Proxy (Variant r) -> TsBridgeM TsType
tsBridge
type class method implementation for the Variant typeSee this reference for details.
Instances
(RowToList r rl, TsBridgeVariantRL tok rl) => TsBridgeVariant tok r
#TsBridgeVariantEncodedFlat Source
class TsBridgeVariantEncodedFlat :: Type -> Symbol -> Row Type -> Constraint
class TsBridgeVariantEncodedFlat tok symTag r where
Members
tsBridgeVariantEncodedFlat :: tok -> Proxy (VariantEncodedFlat symTag r) -> TsBridgeM TsType
tsBridge
type class method implementation for theTsBridgeVariantEncodedFlat
typeSee this reference for details.
Instances
(RowToList r rl, TsBridgeVariantEncodedFlatRL tok symTag rl) => TsBridgeVariantEncodedFlat tok symTag r
#TsBridgeVariantEncodedFlatRL Source
class TsBridgeVariantEncodedFlatRL :: Type -> Symbol -> RowList Type -> Constraint
class TsBridgeVariantEncodedFlatRL tok symTag rl where
Members
tsBridgeVariantEncodedFlatRL :: tok -> Proxy symTag -> Proxy rl -> TsBridgeM (Array TsType)
tsBridge
type class method implementation for theTsBridgeVariantEncodedNested
typeSee this reference for details.
Instances
TsBridgeVariantEncodedFlatRL tok symTag Nil
(TsBridgeBy tok a, TsBridgeVariantEncodedFlatRL tok symTag rl, IsSymbol s, IsSymbol symTag) => TsBridgeVariantEncodedFlatRL tok symTag (Cons s a rl)
#TsBridgeVariantEncodedNested Source
class TsBridgeVariantEncodedNested :: Type -> Symbol -> Symbol -> Row Type -> Constraint
class TsBridgeVariantEncodedNested tok symTag symVal r where
Members
tsBridgeVariantEncodedNested :: tok -> Proxy (VariantEncodedNested symTag symVal r) -> TsBridgeM TsType
tsBridge
type class method implementation for the VariantEncodedNested typeSee this reference for details.
Instances
(RowToList r rl, TsBridgeVariantEncodedNestedRL tok symTag symVal rl) => TsBridgeVariantEncodedNested tok symTag symVal r
#TsBridgeVariantEncodedNestedRL Source
class TsBridgeVariantEncodedNestedRL :: Type -> Symbol -> Symbol -> RowList Type -> Constraint
class TsBridgeVariantEncodedNestedRL tok symTag symVal rl where
Members
tsBridgeVariantEncodedNestedRL :: tok -> Proxy symTag -> Proxy symVal -> Proxy rl -> TsBridgeM (Array TsType)
Instances
TsBridgeVariantEncodedNestedRL tok symTag symVal Nil
(TsBridgeBy tok t, TsBridgeVariantEncodedNestedRL tok symTag symVal rl, IsSymbol s, IsSymbol symTag, IsSymbol symVal) => TsBridgeVariantEncodedNestedRL tok symTag symVal (Cons s t rl)
#TsBridgeVariantRL Source
class TsBridgeVariantRL :: Type -> RowList Type -> Constraint
class TsBridgeVariantRL tok rl where
Members
tsBridgeVariantRL :: tok -> Proxy rl -> TsBridgeM (Array TsType)
Instances
TsBridgeVariantRL tok Nil
(TsBridgeBy tok t, TsBridgeVariantRL tok rl, IsSymbol s) => TsBridgeVariantRL tok (Cons s t rl)
#tsBridgeUnit Source
tsBridgeUnit :: Proxy Unit -> TsBridgeM TsType
tsBridge
type class method implementation for the Unit
type
See this reference for details.
#tsBridgeUndefined Source
tsBridgeUndefined :: Proxy Undefined -> TsBridgeM TsType
tsBridge
type class method implementation for the Undefined
type.
#tsBridgeTypeVar Source
tsBridgeTypeVar :: forall s. IsSymbol s => Proxy (TypeVar s) -> TsBridgeM TsType
tsBridge
type class method implementation for type variables.
This is needed because polymorphic values cannot be exported directly.
They have to be monomorphized: E.g. something of type Maybe a
needs to be
typed Maybe (Var "A")
to be exported.
#tsBridgeTuple Source
tsBridgeTuple :: forall tok a b. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (Tuple a b) -> TsBridgeM TsType
tsBridge type class method implementation for the Tuple
type
See this reference for details.
#tsBridgeStringLit' Source
tsBridgeStringLit' :: forall h. Reflectable h String => Proxy (Lit h String) -> TsBridgeM TsType
#tsBridgeString Source
tsBridgeString :: Proxy String -> TsBridgeM TsType
tsBridge
type class method implementation for the String
type
See this reference for details.
#tsBridgePromise Source
tsBridgePromise :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Promise a) -> TsBridgeM TsType
tsBridge
type class method implementation for the Promise
type.
See this reference for details.
#tsBridgeOneOf Source
tsBridgeOneOf :: forall a b tok. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (OneOf a b) -> TsBridgeM TsType
tsBridge
type class method implementation for the OneOf
type.
See this reference for details.
#tsBridgeObject Source
tsBridgeObject :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Object a) -> TsBridgeM TsType
#tsBridgeNumber Source
tsBridgeNumber :: Proxy Number -> TsBridgeM TsType
tsBridge
type class method implementation for the Number
type.
See this reference for details.
#tsBridgeNullable Source
tsBridgeNullable :: forall a tok. TsBridgeBy tok a => tok -> Proxy (Nullable a) -> TsBridgeM TsType
tsBridge
type class method implementation for the Nullable
type.
See this reference for details.
#tsBridgeNTuple Source
tsBridgeNTuple :: forall tok xs. NTupleList tok xs => tok -> Proxy (NTuple xs) -> TsBridgeM TsType
#tsBridgeMaybe Source
tsBridgeMaybe :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Maybe a) -> TsBridgeM TsType
tsBridge
type class method implementation for the Maybe
type
See this reference for details.
#tsBridgeIntLit' Source
tsBridgeIntLit' :: forall h. Reflectable h Int => Proxy (Lit h Int) -> TsBridgeM TsType
#tsBridgeInt Source
tsBridgeInt :: Proxy Int -> TsBridgeM TsType
tsBridge
type class method implementation for the Int
type
See this reference for details.
#tsBridgeFunction Source
tsBridgeFunction :: forall tok a b. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (a -> b) -> TsBridgeM TsType
tsBridge
type class method implementation for the a -> b
(Function) type
See this reference for details.
#tsBridgeFn4 Source
tsBridgeFn4 :: forall tok a1 a2 a3 a4 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok a3 => TsBridgeBy tok a4 => TsBridgeBy tok b => tok -> Proxy (Fn4 a1 a2 a3 a4 b) -> TsBridgeM TsType
#tsBridgeFn3 Source
tsBridgeFn3 :: forall tok a1 a2 a3 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok a3 => TsBridgeBy tok b => tok -> Proxy (Fn3 a1 a2 a3 b) -> TsBridgeM TsType
#tsBridgeFn2 Source
tsBridgeFn2 :: forall tok a1 a2 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok b => tok -> Proxy (Fn2 a1 a2 b) -> TsBridgeM TsType
#tsBridgeEither Source
tsBridgeEither :: forall tok a b. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (Either a b) -> TsBridgeM TsType
tsBridge
type class method implementation for the Either
type
See this reference for details.
#tsBridgeEffectFn4 Source
tsBridgeEffectFn4 :: forall tok a1 a2 a3 a4 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok a3 => TsBridgeBy tok a4 => TsBridgeBy tok b => tok -> Proxy (EffectFn4 a1 a2 a3 a4 b) -> TsBridgeM TsType
#tsBridgeEffectFn3 Source
tsBridgeEffectFn3 :: forall tok a1 a2 a3 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok a3 => TsBridgeBy tok b => tok -> Proxy (EffectFn3 a1 a2 a3 b) -> TsBridgeM TsType
#tsBridgeEffectFn2 Source
tsBridgeEffectFn2 :: forall tok a1 a2 b. TsBridgeBy tok a1 => TsBridgeBy tok a2 => TsBridgeBy tok b => tok -> Proxy (EffectFn2 a1 a2 b) -> TsBridgeM TsType
#tsBridgeEffectFn1 Source
tsBridgeEffectFn1 :: forall tok a1 b. TsBridgeBy tok a1 => TsBridgeBy tok b => tok -> Proxy (EffectFn1 a1 b) -> TsBridgeM TsType
#tsBridgeEffect Source
tsBridgeEffect :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Effect a) -> TsBridgeM TsType
tsBridge
type class method implementation for the Effect
type
See this reference for details.
#tsBridgeChar Source
tsBridgeChar :: Proxy Char -> TsBridgeM TsType
tsBridge
type class method implementation for the Char
type
See this reference for details.
#tsBridgeBooleanLitTrue Source
tsBridgeBooleanLitTrue :: Proxy (BooleanLit "true") -> TsBridgeM TsType
#tsBridgeBooleanLitFalse Source
tsBridgeBooleanLitFalse :: Proxy (BooleanLit "false") -> TsBridgeM TsType
#tsBridgeBooleanLit' Source
tsBridgeBooleanLit' :: forall h. Reflectable h Boolean => Proxy (Lit h Boolean) -> TsBridgeM TsType
#tsBridgeBoolean Source
tsBridgeBoolean :: Proxy Boolean -> TsBridgeM TsType
tsBridge
type class method implementation for the Boolean
type
See this reference for details.
#tsBridgeArray Source
tsBridgeArray :: forall a tok. TsBridgeBy tok a => tok -> Proxy (Array a) -> TsBridgeM TsType
tsBridge
type class method implementation for the Array
type
See this reference for details.
Re-exports from TsBridge.Monad
#TsBridgeAccum Source
newtype TsBridgeAccum
Constructors
TsBridgeAccum { registeredTypes :: Set { moduleName :: String, typeName :: String }, scope :: Scope, typeDefs :: Array TsModuleFile }
Instances
#runTsBridgeM Source
runTsBridgeM :: forall a. TsBridgeM a -> Either AppError (a /\ TsBridgeAccum)
Re-exports from TsBridge.Types
#PursModuleName Source
newtype PursModuleName
#CapError Source
class CapError :: (Type -> Type) -> Constraint
class (MonadError AppError m) <= CapError m
#CapThrow Source
class CapThrow :: (Type -> Type) -> Constraint
class (MonadThrow AppError m) <= CapThrow m
#unsafeName Source
unsafeName :: String -> Name
#printError Source
printError :: AppError -> String
#mkPursModuleName Source
mkPursModuleName :: forall m. MonadError AppError m => String -> m PursModuleName
#mapErr Source
mapErr :: forall e m a. MonadError e m => (e -> e) -> m a -> m a
Re-exports from TsBridge.Types.Intersection
#tsBridgeIntersection Source
tsBridgeIntersection :: forall a b tok. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (Intersection a b) -> TsBridgeM TsType
#toTuple Source
toTuple :: forall a b. Intersection a b -> Tuple a b
#snd Source
snd :: forall a b. Intersection a b -> b
#fst Source
fst :: forall a b. Intersection a b -> a
#type (|&|) Source
Operator alias for TsBridge.Types.Intersection.Intersection (right-associative / precedence 7)
Re-exports from TsBridge.Types.TsRecord
#Mod Source
data Mod :: Row Boolean -> Type -> ModField Type
data Mod t0 t1
Instances
(ToRecordBuilder rl' rts r', Cons sym (Mod mods a) rtsx rts, Cons sym a_ r' r, Lacks sym r', IsSymbol sym, Get sym rts a_) => ToRecordBuilder (Cons sym (Mod mods a) rl') rts r
(TsBridgeBy tok t, TsBridgeTsRecordRL tok rl, IsSymbol s, GetMods mods) => TsBridgeTsRecordRL tok (Cons s (Mod mods t) rl)
#Get Source
#GetModsRL Source
class GetModsRL :: RowList Boolean -> Constraint
class GetModsRL rl where
Members
getModsRL :: Proxy rl -> PropModifiers
Instances
#ToRecordBuilder Source
class ToRecordBuilder :: RowList (ModField Type) -> Row (ModField Type) -> Row Type -> Constraint
class ToRecordBuilder rl rts r | rl rts -> r where
Members
toRecordBuilder :: forall proxy. proxy rl -> TsRecord rts -> Builder (Record ()) (Record r)
Instances
ToRecordBuilder Nil rts ()
(ToRecordBuilder rl' rts r', Cons sym (Mod mods a) rtsx rts, Cons sym a_ r' r, Lacks sym r', IsSymbol sym, Get sym rts a_) => ToRecordBuilder (Cons sym (Mod mods a) rl') rts r
#TsBridgeTsRecord Source
class TsBridgeTsRecord :: Type -> Row (ModField Type) -> Constraint
class TsBridgeTsRecord tok r where
Members
tsBridgeTsRecord :: tok -> Proxy (TsRecord r) -> TsBridgeM TsType
Instances
(RowToList r rl, TsBridgeTsRecordRL tok rl) => TsBridgeTsRecord tok r
#TsBridgeTsRecordRL Source
class TsBridgeTsRecordRL :: Type -> RowList (ModField Type) -> Constraint
class TsBridgeTsRecordRL tok rl where
Members
tsBridgeTsRecordRL :: tok -> Proxy rl -> TsBridgeM (Array TsRecordField)
Instances
TsBridgeTsRecordRL tok Nil
(TsBridgeBy tok t, TsBridgeTsRecordRL tok rl, IsSymbol s, GetMods mods) => TsBridgeTsRecordRL tok (Cons s (Mod mods t) rl)
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 }