on c18bebe help sign in
elk/libraries/JavaScript.elm
72 lines 1.7 kB history raw
2module JavaScript where
4{-|This library does basic conversions between Elm and JS values. This allows
5the internal data structures of Elm to change and improve with no impact on JS
6integration.
8# Javascript to Elm
9@docs toString, toInt, toFloat, toBool, toList
11# JavaScript from Elm
12@docs fromString, fromInt, fromFloat, fromBool fromList
14-}
15{-
16# DOM Nodes and Elements
17@docs toElement, fromElement
18-}
20import Native.JavaScript
21import open Basics
23data JSNumber = JSNumber
24data JSBool = JSBool
25data JSString = JSString
26data JSArray a = JSArray a
27data JSDomNode = JSDomNode
28data JSObject = JSObject
30-- Requires that the input array be uniform (all members have the same type)
31toList : JSArray a -> [a]
32toList = Native.JavaScript.toList
34toInt : JSNumber -> Int
35toInt = Native.JavaScript.toInt
37toFloat : JSNumber -> Float
38toFloat = Native.JavaScript.toFloat
40toBool : JSBool -> Bool
41toBool = Native.JavaScript.toBool
43toString : JSString -> String
44toString = Native.JavaScript.toString
47-- Produces a uniform JavaScript array with all members of the same type.
48fromList : [a] -> JSArray a
49fromList = Native.JavaScript.fromList
51fromInt : Int -> JSNumber
52fromInt = Native.JavaScript.fromInt
54fromFloat : Float -> JSNumber
55fromFloat = Native.JavaScript.fromFloat
57fromBool : Bool -> JSBool
58fromBool = Native.JavaScript.fromBool
60fromString : String -> JSString
61fromString = Native.JavaScript.fromString
63{--
64{-| Turn an `Element` into a DOM node. -}
65fromElement : Element -> JSDomNode
66fromElement = Native.JavaScript.fromElement
68{-| Turn a DOM node into an `Element`. You can resize the node
69using the normal `width` and `height` functions. -}
70toElement : Int -> Int -> JSDomNode -> Element
71toElement = Native.JavaScript.toElement
72--}