Move show function to String library and get rid of Prelude library

This commit is contained in:
Evan Czaplicki 2014-03-01 13:58:02 -05:00
parent cc3c8704e2
commit 74d0482ace
5 changed files with 17 additions and 16 deletions

View file

@ -20,12 +20,12 @@ add noPrelude (Module name exs ims decls) = Module name exs (customIms ++ ims) d
Just _ -> [] Just _ -> []
prelude :: [(String, ImportMethod)] prelude :: [(String, ImportMethod)]
prelude = string : text ++ map (\n -> (n, Hiding [])) modules prelude = string ++ text ++ map (\n -> (n, Hiding [])) modules
where where
text = map ((,) "Text") [ As "Text", Hiding ["link", "color", "height"] ] text = map ((,) "Text") [ As "Text", Hiding ["link", "color", "height"] ]
string = ("String", As "String") string = map ((,) "String") [ As "String", Importing ["show"] ]
modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Prelude" modules = [ "Basics", "Signal", "List", "Maybe", "Time", "Color"
, "Graphics.Element", "Color", "Graphics.Collage", "Native.Ports" ] , "Graphics.Element", "Graphics.Collage", "Native.Ports" ]
interfaces :: Bool -> IO Interfaces interfaces :: Bool -> IO Interfaces
interfaces noPrelude = interfaces noPrelude =

View file

@ -35,7 +35,6 @@ import Basics (..)
import Maybe (..) import Maybe (..)
import Native.Error import Native.Error
import List import List
import String
import Native.Utils import Native.Utils
-- BBlack and NBlack should only be used during the deletion -- BBlack and NBlack should only be used during the deletion
@ -197,7 +196,7 @@ lessBlackTree t = case t of
reportRemBug : String -> NColor -> String -> String -> a reportRemBug : String -> NColor -> String -> String -> a
reportRemBug msg c lgot rgot = reportRemBug msg c lgot rgot =
Native.Error.raise . String.concat <| [ Native.Error.raise <| List.concat [
"Internal red-black tree invariant violated, expected ", "Internal red-black tree invariant violated, expected ",
msg, msg,
"and got", "and got",

View file

@ -10,6 +10,7 @@ Elm.Native.String.make = function(elm) {
var Maybe = Elm.Maybe.make(elm); var Maybe = Elm.Maybe.make(elm);
var JS = Elm.JavaScript.make(elm); var JS = Elm.JavaScript.make(elm);
var Utils = Elm.Native.Utils.make(elm); var Utils = Elm.Native.Utils.make(elm);
var show = Elm.Native.Show.make(elm);
function isEmpty(str) { function isEmpty(str) {
return str.length === 0; return str.length === 0;
@ -243,9 +244,10 @@ Elm.Native.String.make = function(elm) {
endsWith: F2(endsWith), endsWith: F2(endsWith),
indexes: F2(indexes), indexes: F2(indexes),
show:show,
toInt: toInt, toInt: toInt,
toFloat: toFloat, toFloat: toFloat,
toList: toList, toList: toList,
fromList: fromList, fromList: fromList,
}; };
}; };

View file

@ -1,8 +0,0 @@
module Prelude where
{-| Everything that is automatically imported -}
import Native.Show
-- Convert almost any value to its string representation.
show : a -> String
show = Native.Show.show

View file

@ -15,7 +15,7 @@ are enclosed in `"double quotes"`. Strings are *not* lists of characters.
@docs contains, startsWith, endsWith, indexes, indices @docs contains, startsWith, endsWith, indexes, indices
# Conversions # Conversions
@docs toInt, toFloat, toList, fromList @docs show, toInt, toFloat, toList, fromList
# Formatting # Formatting
Cosmetic operations such as padding with extra characters or trimming whitespace. Cosmetic operations such as padding with extra characters or trimming whitespace.
@ -278,6 +278,14 @@ indexes = Native.String.indexes
indices : String -> String -> [Int] indices : String -> String -> [Int]
indices = Native.String.indexes indices = Native.String.indexes
{-| Turn any kind of value into a string.
show 42 == "42"
show [1,2] == "[1,2]"
-}
show : a -> String
show = Native.String.show
{-| Try to convert a string into an int, failing on improperly formatted strings. {-| Try to convert a string into an int, failing on improperly formatted strings.
toInt "123" == Just 123 toInt "123" == Just 123