on master help sign in
Move show function to String library and get rid of Prelude library
commit74d0482ace8fd3b5ab2b310a13d4882f22c29bc6 authorEvan Czaplicki <info@elm-lang.org> dateSat 1 Mar 2014, 13:58 (13 years ago) parentcc3c870
5 files changed+17−16
compiler/Metadata/Prelude.hs+4−4 libraries/Dict.elm+1−2 libraries/Native/String.js+3−1 libraries/Prelude.elm−8 libraries/String.elm+9−1
compiler/Metadata/Prelude.hs+4−4
@@ -20,12 +20,12 @@ add noPrelude (Module name exs ims decls) = Module name exs (customIms ++ ims) d
2020 Just _ -> []
2121
2222prelude :: [(String, ImportMethod)]
23−prelude = string : text ++ map (\n -> (n, Hiding [])) modules
23+prelude = string ++ text ++ map (\n -> (n, Hiding [])) modules
2424 where
2525 text = map ((,) "Text") [ As "Text", Hiding ["link", "color", "height"] ]
26− string = ("String", As "String")
27− modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Prelude"
28− , "Graphics.Element", "Color", "Graphics.Collage", "Native.Ports" ]
26+ string = map ((,) "String") [ As "String", Importing ["show"] ]
27+ modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Color"
28+ , "Graphics.Element", "Graphics.Collage", "Native.Ports" ]
2929
3030interfaces :: Bool -> IO Interfaces
3131interfaces noPrelude =
libraries/Dict.elm+1−2
@@ -35,7 +35,6 @@ import Basics (..)
3535import Maybe (..)
3636import Native.Error
3737import List
38−import String
3938import Native.Utils
4039
4140-- BBlack and NBlack should only be used during the deletion
@@ -197,7 +196,7 @@ lessBlackTree t = case t of
197196
198197reportRemBug : String -> NColor -> String -> String -> a
199198reportRemBug msg c lgot rgot =
200− Native.Error.raise . String.concat <| [
199+ Native.Error.raise <| List.concat [
201200 "Internal red-black tree invariant violated, expected ",
202201 msg,
203202 "and got",
libraries/Native/String.js+3−1
@@ -10,6 +10,7 @@ Elm.Native.String.make = function(elm) {
1010 var Maybe = Elm.Maybe.make(elm);
1111 var JS = Elm.JavaScript.make(elm);
1212 var Utils = Elm.Native.Utils.make(elm);
13+ var show = Elm.Native.Show.make(elm);
1314
1415 function isEmpty(str) {
1516 return str.length === 0;
@@ -243,9 +244,10 @@ Elm.Native.String.make = function(elm) {
243244 endsWith: F2(endsWith),
244245 indexes: F2(indexes),
245246
247+ show:show,
246248 toInt: toInt,
247249 toFloat: toFloat,
248250 toList: toList,
249251 fromList: fromList,
250252 };
251−};
253+};
libraries/Prelude.elmdeleted−8
@@ -1,8 +0,0 @@
1−module Prelude where
2−{-| Everything that is automatically imported -}
3−
4−import Native.Show
5−
6−-- Convert almost any value to its string representation.
7−show : a -> String
8−show = Native.Show.show
libraries/String.elm+9−1
@@ -15,7 +15,7 @@ are enclosed in `"double quotes"`. Strings are *not* lists of characters.
1515@docs contains, startsWith, endsWith, indexes, indices
1616
1717# Conversions
18−@docs toInt, toFloat, toList, fromList
18+@docs show, toInt, toFloat, toList, fromList
1919
2020# Formatting
2121Cosmetic operations such as padding with extra characters or trimming whitespace.
@@ -278,6 +278,14 @@ indexes = Native.String.indexes
278278indices : String -> String -> [Int]
279279indices = Native.String.indexes
280280
281+{-| Turn any kind of value into a string.
282+
283+ show 42 == "42"
284+ show [1,2] == "[1,2]"
285+-}
286+show : a -> String
287+show = Native.String.show
288+
281289{-| Try to convert a string into an int, failing on improperly formatted strings.
282290
283291 toInt "123" == Just 123