diff --git a/compiler/src/Data/Name.hs b/compiler/src/Data/Name.hs index c3a8b939..3028b042 100644 --- a/compiler/src/Data/Name.hs +++ b/compiler/src/Data/Name.hs @@ -39,7 +39,6 @@ module Data.Name result, array, dict, - tuple, jsArray, task, router, @@ -426,10 +425,6 @@ array = fromChars "Array" dict :: Name dict = fromChars "Dict" -{-# NOINLINE tuple #-} -tuple :: Name -tuple = fromChars "Tuple" - {-# NOINLINE jsArray #-} jsArray :: Name jsArray = fromChars "JsArray" diff --git a/compiler/src/Generate/JavaScript/Expression.hs b/compiler/src/Generate/JavaScript/Expression.hs index dd769d3a..31d86148 100644 --- a/compiler/src/Generate/JavaScript/Expression.hs +++ b/compiler/src/Generate/JavaScript/Expression.hs @@ -314,23 +314,9 @@ generateCoreCall mode (Opt.Global home@(ModuleName.Canonical _ moduleName) name) if moduleName == Name.bitwise then generateBitwiseCall home name (map (generateJsExpr mode) args) else - if moduleName == Name.tuple - then generateTupleCall home name (map (generateJsExpr mode) args) - else - if moduleName == Name.jsArray - then generateJsArrayCall home name (map (generateJsExpr mode) args) - else generateGlobalCall home name (map (generateJsExpr mode) args) - -generateTupleCall :: ModuleName.Canonical -> Name.Name -> [JS.Expr] -> JS.Expr -generateTupleCall home name args = - case args of - [value] -> - case name of - "first" -> JS.Access value (JsName.fromLocal "a") - "second" -> JS.Access value (JsName.fromLocal "b") - _ -> generateGlobalCall home name args - _ -> - generateGlobalCall home name args + if moduleName == Name.jsArray + then generateJsArrayCall home name (map (generateJsExpr mode) args) + else generateGlobalCall home name (map (generateJsExpr mode) args) generateJsArrayCall :: ModuleName.Canonical -> Name.Name -> [JS.Expr] -> JS.Expr generateJsArrayCall home name args = diff --git a/compiler/src/Gren/Compiler/Imports.hs b/compiler/src/Gren/Compiler/Imports.hs index 9c089b8a..2279f5bc 100644 --- a/compiler/src/Gren/Compiler/Imports.hs +++ b/compiler/src/Gren/Compiler/Imports.hs @@ -22,7 +22,6 @@ defaults = import_ ModuleName.result Nothing (typeOpen Name.result), import_ ModuleName.string Nothing (typeClosed Name.string), import_ ModuleName.char Nothing (typeClosed Name.char), - import_ ModuleName.tuple Nothing closed, import_ ModuleName.platform Nothing (typeClosed Name.program), import_ ModuleName.cmd (Just Name.cmd) (typeClosed Name.cmd), import_ ModuleName.sub (Just Name.sub) (typeClosed Name.sub) diff --git a/compiler/src/Gren/ModuleName.hs b/compiler/src/Gren/ModuleName.hs index 3a646b22..f78934bb 100644 --- a/compiler/src/Gren/ModuleName.hs +++ b/compiler/src/Gren/ModuleName.hs @@ -20,7 +20,6 @@ module Gren.ModuleName result, array, dict, - tuple, platform, cmd, sub, @@ -162,10 +161,6 @@ array = Canonical Pkg.core Name.array dict :: Canonical dict = Canonical Pkg.core Name.dict -{-# NOINLINE tuple #-} -tuple :: Canonical -tuple = Canonical Pkg.core Name.tuple - {-# NOINLINE platform #-} platform :: Canonical platform = Canonical Pkg.core Name.platform diff --git a/compiler/src/Reporting/Error/Main.hs b/compiler/src/Reporting/Error/Main.hs index d8a22f6c..3da7f911 100644 --- a/compiler/src/Reporting/Error/Main.hs +++ b/compiler/src/Reporting/Error/Main.hs @@ -97,7 +97,7 @@ toReport localizer source err = D.indent 4 $ D.reflow $ "Ints, Floats, Bools, Strings, Maybes, Lists, Arrays,\ - \ tuples, records, and JSON values.", + \ records, and JSON values.", D.reflow $ "Since JSON values can flow through, you can use JSON encoders and decoders\ \ to allow other types through as well. More advanced users often just do\ diff --git a/hints/imports.md b/hints/imports.md index a41be2a3..179974f3 100644 --- a/hints/imports.md +++ b/hints/imports.md @@ -109,7 +109,6 @@ import List exposing (List, (::)) import Maybe exposing (Maybe(..)) import Result exposing (Result(..)) import String -import Tuple import Debug diff --git a/hints/tuples.md b/hints/tuples.md deleted file mode 100644 index 635949d6..00000000 --- a/hints/tuples.md +++ /dev/null @@ -1,18 +0,0 @@ -# From Tuples to Records - -The largest tuple possible in Gren has three entries. Once you get to four, it is best to make a record with named entries. - -For example, it is _conceivable_ to represent a rectangle as four numbers like `(10,10,100,100)` but it would be more self-documenting to use a record like this: - -```gren -type alias Rectangle = - { x : Float - , y : Float - , width : Float - , height : Float - } -``` - -Now it is clear that the dimensions should be `Float` values. It is also clear that we are not using the convention of specifying the top-left and bottom-right corners. It could be clearer about whether the `x` and `y` is the point in the top-left or in the middle though! - -Anyway, using records like this also gives you access to syntax like `rect.x`, `.x`, and `{ rect | x = 40 }`. It is not clear how to design features like that for arbitrarily sized tuples, so we did not. We already have a way, and it is more self-documenting! diff --git a/hints/type-annotations.md b/hints/type-annotations.md index 26262844..c8230aa9 100644 --- a/hints/type-annotations.md +++ b/hints/type-annotations.md @@ -10,15 +10,15 @@ This document is going to outline the various things that can go wrong and show The most common issue is with user-defined type variables that are too general. So let's say you have defined a function like this: ```gren -addPair : (a, a) -> a -addPair (x, y) = +addPair : a -> a -> a +addPair x y = x + y ``` -The issue is that the type annotation is saying "I will accept a tuple containing literally *anything*" but the definition is using `(+)` which requires things to be numbers. So the compiler is going to infer that the true type of the definition is this: +The issue is that the type annotation is saying "I will accept two parameters that can be literally *anything*" but the definition is using `(+)` which requires things to be numbers. So the compiler is going to infer that the true type of the definition is this: ```gren -addPair : (number, number) -> number +addPair : number -> number -> -> number ``` So you will probably see an error saying "I cannot match `a` with `number`" which is essentially saying, you are trying to provide a type annotation that is **too general**. You are saying `addPair` accepts anything, but in fact, it can only handle numbers. @@ -31,8 +31,8 @@ In cases like this, you want to go with whatever the compiler inferred. It is go It is also possible to have a type annotation that clashes with itself. This is probably more rare, but someone will run into it eventually. Let's use another version of `addPair` with problems: ```gren -addPair : (Int, Int) -> number -addPair (x, y) = +addPair : Int -> Int -> number +addPair x y = x + y ```