Module

Elmish.Foreign

Package
purescript-elmish
Repository
collegevine/purescript-elmish

#CanPassToJavaScript Source

class CanPassToJavaScript a 

This class is used to assert that values of a type can be passed to JavaScript code directly (without conversion) and understood by that code. Specifically, this class is defined for primitives (strings, numbers, booleans), arrays, and records. This assertion is used in a number of places that pass complex values to JS code to restrict the types that can be safely passed.

Instances

#readForeign Source

readForeign :: forall a. CanReceiveFromJavaScript a => Foreign -> Maybe a

Verifies if the given raw JS value is of the right type/shape to be represented as a, and if so, coerces the value to a.

#argumentsToArray_ Source

argumentsToArray_ :: Arguments -> Array Foreign

Creates a new Array from an Arguments object.

#getArgument Source

getArgument :: Arguments -> Int -> Maybe Foreign

Gets the value at a specified index of an Arguments object. Returns Nothing if there are not enough arguments.

#mkVarArgEff_ Source

mkVarArgEff_ :: (Arguments -> Effect Unit) -> Foreign

Creates a JS function that takes a variable number of args (via arguments) and calls the provided effectful continuation, passing the arguments as an array.

#CanReceiveFromJavaScriptRecord Source

class CanReceiveFromJavaScriptRecord rowList  where

This class is implementation of isForeignOfCorrectType for records. It validates a given JS hash (aka "object") against a given type row that represents a PureScript record, recursively calling isForeignOfCorrectType for each field.

Members

Instances

#CanPassToJavaScriptRecord Source

class CanPassToJavaScriptRecord (rowList :: RowList) 

This class is implementation of CanPassToJavaScript for records. It simply iterates over all fields, checking that every field is of a type that also has an instance of CanPassToJavaScript.

Instances

Re-exports from Foreign

#Foreign Source

data Foreign :: Type

A type for foreign data.

Foreign data is data from any external unknown or unreliable source, for which it cannot be guaranteed that the runtime representation conforms to that of any particular type.

Suitable applications of Foreign are

  • To represent responses from web services
  • To integrate with external JavaScript libraries.