elm/libraries/JavaScript.elm

73 lines
1.7 KiB
Elm
Raw Normal View History

module JavaScript where
2013-09-10 13:46:26 +00:00
{-|This library does basic conversions between Elm and JS values. This allows
the internal data structures of Elm to change and improve with no impact on JS
integration.
# Javascript to Elm
@docs toString, toInt, toFloat, toBool, toList
# JavaScript from Elm
@docs fromString, fromInt, fromFloat, fromBool fromList
-}
{-
# DOM Nodes and Elements
@docs toElement, fromElement
-}
import Native.JavaScript
import open Basics
2013-07-26 09:42:00 +00:00
data JSNumber = JSNumber
data JSBool = JSBool
data JSString = JSString
data JSArray a = JSArray a
data JSDomNode = JSDomNode
2013-07-26 14:38:11 +00:00
data JSObject = JSObject
-- Requires that the input array be uniform (all members have the same type)
2013-03-10 08:54:37 +00:00
toList : JSArray a -> [a]
toList = Native.JavaScript.toList
2013-07-26 09:42:00 +00:00
toInt : JSNumber -> Int
toInt = Native.JavaScript.toInt
2013-07-26 09:42:00 +00:00
toFloat : JSNumber -> Float
toFloat = Native.JavaScript.toFloat
2013-07-26 09:42:00 +00:00
toBool : JSBool -> Bool
toBool = Native.JavaScript.toBool
2013-07-26 09:42:00 +00:00
toString : JSString -> String
toString = Native.JavaScript.toString
-- Produces a uniform JavaScript array with all members of the same type.
2013-03-10 08:54:37 +00:00
fromList : [a] -> JSArray a
fromList = Native.JavaScript.fromList
2013-07-26 09:42:00 +00:00
fromInt : Int -> JSNumber
fromInt = Native.JavaScript.fromInt
2013-07-26 09:42:00 +00:00
fromFloat : Float -> JSNumber
fromFloat = Native.JavaScript.fromFloat
2013-07-26 09:42:00 +00:00
fromBool : Bool -> JSBool
fromBool = Native.JavaScript.fromBool
2013-07-26 09:42:00 +00:00
fromString : String -> JSString
fromString = Native.JavaScript.fromString
{--
2013-09-10 13:46:26 +00:00
{-| Turn an `Element` into a DOM node. -}
fromElement : Element -> JSDomNode
fromElement = Native.JavaScript.fromElement
2013-09-10 13:46:26 +00:00
{-| Turn a DOM node into an `Element`. You can resize the node
using the normal `width` and `height` functions. -}
toElement : Int -> Int -> JSDomNode -> Element
toElement = Native.JavaScript.toElement
2013-09-10 13:46:26 +00:00
--}