TsBridge
- Package
- purescript-ts-bridge
- Repository
- thought2/purescript-ts-bridge
Re-exports from TsBridge.Cli
Re-exports from TsBridge.Core
#StandaloneTsType Source
type StandaloneTsType = TsBridgeM TsType
A StandaloneTsType
represents a TypeScript type with everything it needs
to be placed inside complete TS program: If the type references nominal
types from other modules, all information is contained that is needed to
render those references.
#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 -> StandaloneTsType
#TsValues Source
class TsValues :: Type -> Row Type -> Constraint
class TsValues tok r where
Members
tsValues :: tok -> Record r -> TsBridgeM (Array TsDeclaration)
Instances
(TsValuesRL tok r rl, RowToList r rl) => TsValues tok r
#TsValuesRL Source
class TsValuesRL :: Type -> Row Type -> RowList Type -> Constraint
class TsValuesRL tok r rl where
Members
tsValuesRL :: tok -> Record r -> Proxy rl -> TsBridgeM (Array TsDeclaration)
Instances
TsValuesRL tok r Nil
(TsValuesRL tok r rl, TsBridgeBy tok a, Cons sym a rx r, IsSymbol sym) => TsValuesRL tok r (Cons sym a rl)
#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.
#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 Error (Array TsModuleFile)
Re-exports from TsBridge.DTS
#TsTypeArgsQuant Source
#TsType Source
data TsType
Represents a subset of TypeScript types
Constructors
TsTypeNumber
TsTypeString
TsTypeBoolean
TsTypeNull
TsTypeArray TsType
TsTypeReadonlyArray TsType
TsTypeIntersection (Array TsType)
TsTypeUnion (Array TsType)
TsTypeRecord (Array TsRecordField)
TsTypeFunction TsTypeArgsQuant (Array TsFnArg) TsType
TsTypeConstructor TsQualName TsTypeArgs
TsTypeUniqueSymbol
TsTypeVar TsName
TsTypeTypelevelString String
TsTypeVoid
Instances
#TsRecordField Source
#TsQualName Source
#TsNameError Source
#TsDeclaration Source
data TsDeclaration
Represents a subset of TypeScript type declarations
Constructors
TsDeclTypeDef TsName TsDeclVisibility (OSet TsName) TsType
TsDeclValueDef TsName TsDeclVisibility TsType
TsDeclComments (Array String)
Instances
#PropModifiers Source
type PropModifiers = { optional :: Boolean, readonly :: Boolean }
#unsafeTsName Source
unsafeTsName :: String -> TsName
#printTsName Source
printTsName :: TsName -> String
#printError Source
printError :: Error -> String
#dtsFilePath Source
dtsFilePath :: String -> TsFilePath
Re-exports from TsBridge.DefaultImpls
#TsBridgeRecord Source
class TsBridgeRecord :: Type -> Row Type -> Constraint
class TsBridgeRecord tok r where
Members
tsBridgeRecord :: tok -> Proxy (Record r) -> StandaloneTsType
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) -> StandaloneTsType
tsBridge
type class method implementation for the Variant typeSee this reference for details.
Instances
(RowToList r rl, TsBridgeVariantRL tok rl) => TsBridgeVariant tok r
#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 -> StandaloneTsType
tsBridge
type class method implementation for the Unit
type
See this reference for details.
#tsBridgeTypeVar Source
tsBridgeTypeVar :: forall s. IsSymbol s => Proxy (TypeVar s) -> StandaloneTsType
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) -> StandaloneTsType
tsBridge type class method implementation for the Tuple
type
See this reference for details.
#tsBridgeString Source
tsBridgeString :: Proxy String -> StandaloneTsType
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) -> StandaloneTsType
tsBridge
type class method implementation for the Promise
type.
See this reference for details.
#tsBridgeOpaqueType Source
tsBridgeOpaqueType :: forall a. String -> String -> Array (String /\ StandaloneTsType) -> a -> StandaloneTsType
tsBridge
type class method implementation for opaque types
#tsBridgeNumber Source
tsBridgeNumber :: Proxy Number -> StandaloneTsType
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) -> StandaloneTsType
tsBridge
type class method implementation for the Nullable
type.
See this reference for details.
#tsBridgeNewtype Source
tsBridgeNewtype :: forall tok a t. Newtype a t => TsBridgeBy tok t => tok -> String -> String -> Array (String /\ StandaloneTsType) -> Proxy a -> StandaloneTsType
tsBridge
type class method implementation for newtypes
#tsBridgeMaybe Source
tsBridgeMaybe :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Maybe a) -> StandaloneTsType
tsBridge
type class method implementation for the Maybe
type
See this reference for details.
#tsBridgeInt Source
tsBridgeInt :: Proxy Int -> StandaloneTsType
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) -> StandaloneTsType
tsBridge
type class method implementation for the a -> b
(Function) type
See this reference for details.
#tsBridgeEither Source
tsBridgeEither :: forall tok a b. TsBridgeBy tok a => TsBridgeBy tok b => tok -> Proxy (Either a b) -> StandaloneTsType
tsBridge
type class method implementation for the Either
type
See this reference for details.
#tsBridgeEffect Source
tsBridgeEffect :: forall tok a. TsBridgeBy tok a => tok -> Proxy (Effect a) -> StandaloneTsType
tsBridge
type class method implementation for the Effect
type
See this reference for details.
#tsBridgeChar Source
tsBridgeChar :: Proxy Char -> StandaloneTsType
tsBridge
type class method implementation for the Char
type
See this reference for details.
#tsBridgeBoolean Source
tsBridgeBoolean :: Proxy Boolean -> StandaloneTsType
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) -> StandaloneTsType
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 { scope :: Scope, typeDefs :: Array TsModuleFile }
Instances
#runTsBridgeM Source
runTsBridgeM :: forall a. TsBridgeM a -> Either Error (a /\ TsBridgeAccum)
Re-exports from TsBridge.Print
#printTsType Source
printTsType :: TsType -> TsSource
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 }