@@ -0,0 +1,144 @@
1+
2+module Prelude where
3+
4+radians : Float -> Float
5+radians t = t
6+
7+degrees : Float -> Float
8+degrees d = Math.pi * d / 180
9+
10+rotations : Float -> Float
11+rotations r = 2 * Math.pi * r
12+
13+-- Integer division, remainder is discarded.
14+div : Int -> Int -> Int
15+
16+-- Finds the remainder after dividing one number by another: 4 `rem` 3 == 1
17+rem : Int -> Int -> Int
18+
19+-- Perform modular arithmetic: 7 `mod` 2 == 1
20+mod : Int -> Int -> Int
21+
22+-- Basic functions of trigonometry.
23+cos : Float -> Float
24+sin : Float -> Float
25+tan : Float -> Float
26+acos : Float -> Float
27+asin : Float -> Float
28+atan : Float -> Float
29+
30+-- Returns the arctangent of the quotient of its arguments in radians.
31+-- So `atan2 y x` computes the angle from the positive x-axis to the vector
32+-- starting at the origin and ending at (x,y).
33+atan2 : Float -> Float -> Float
34+
35+-- Take the square root of a number.
36+sqrt : Number -> Number
37+
38+-- Take the absolute value of a number.
39+abs : Number -> Number
40+
41+-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
42+logBase : Number -> Number -> Number
43+
44+-- Given two numbers, returns the smaller (or greater respectively).
45+min : Number -> Number -> Number
46+max : Number -> Number -> Number
47+
48+-- Clamps a number within a given range, so `clamp 100 200 x` is 200 for
49+-- x >= 200, 100 for x <= 100, and x for any 100 < x < 200
50+clamp : Number -> Number -> Number -> Number
51+
52+-- An approximation of pi.
53+pi : Float
54+
55+-- An approximation of e.
56+e : Float
57+
58+-- Compare any two values for structural equality and inequality.
59+-- Functions cannot be compared.
60+(==) : a -> a -> Bool
61+(/=) : a -> a -> Bool
62+
63+-- Compare any two comparable values. Comparable values include String, Char,
64+-- Int, Float, Time, or a list or tuple containing comparable values.
65+-- These are also the only values that work as Dictionary keys or Set members.
66+(<) : a -> a -> Bool
67+(>) : a -> a -> Bool
68+(<=) : a -> a -> Bool
69+(>=) : a -> a -> Bool
70+
71+-- The and operator. True if both inputs are True.
72+(&&) : Bool -> Bool -> Bool
73+
74+-- The or operator. True if one or both inputs are True.
75+(||) : Bool -> Bool -> Bool
76+
77+-- The exclusive-or operator. True if exactly one input is True.
78+xor : Bool -> Bool -> Bool
79+
80+-- Negate a boolean value: (not True == False) and (not False == True)
81+not : Bool -> Bool
82+
83+-- Equal to true. Useful as the last case of a multi-way-if.
84+otherwise : Bool
85+otherwise = True
86+
87+
88+-- Conversions
89+
90+-- Round a number to the nearest integer.
91+round : Float -> Int
92+
93+-- Truncate a decimal number, rounding towards zero.
94+truncate : Float -> Int
95+
96+-- Floor function, rounding down.
97+floor : Float -> Int
98+
99+-- Ceiling function, rounding up.
100+ceiling : Float -> Int
101+
102+-- Convert an integer into a float.
103+toFloat : Int -> Float
104+
105+-- Convert almost any value to its string representation.
106+show : a -> String
107+
108+-- Read an integer from a string
109+readInt : String -> Maybe Int
110+
111+-- Read a float from a string.
112+readFloat : String -> Maybe Float
113+
114+-- Function Helpers
115+
116+-- Function composition: f . g == (\x -> f (g x))
117+(.) : (b -> c) -> (a -> b) -> (a -> c)
118+
119+-- Function application `f $ x == f x`. This function is useful for avoiding
120+-- parenthesis. Consider the following code to create a text element:
121+-- text (monospace (toText "code"))
122+-- This can also be written as:
123+-- text . monospace $ toText "code"
124+($) : (a -> b) -> a -> b
125+
126+-- Given a value, returns exactly the same value.
127+id : a -> a
128+
129+-- Given a 2-tuple, returns the first value.
130+fst : (a,b) -> a
131+
132+-- Given a 2-tuple, returns the second value.
133+snd : (a,b) -> b
134+
135+-- Flips the order of the first two arguments to a function.
136+flip : (a -> b -> c) -> (b -> a -> c)
137+
138+-- Change how arguments are passed to a function. This splits paired arguments
139+-- into two separate arguments.
140+curry : ((a,b) -> c) -> a -> b -> c
141+
142+-- Change how arguments are passed to a function. This combines two arguments
143+-- into a sigle pair.
144+uncurry : (a -> b -> c) -> (a,b) -> c