Skip to content

panosoft/elm-string-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

String Utils

Some String utils, e.g. better concat

API

Concat things

No need to use toString like with the ++ operator.

(+++) : a -> b -> String
(+++) a b =

Usage

s : String
s =
	"Hello World" +++ "!! " +++ " " +++ ( 1, 2 ) +++ " " +++ { x = [ 3, 4 ], y = "abc" }

This produces the string: Hello World!! (1,2) { x = [3,4], y = "abc" }.

Concat things with a space between

No need to explicitly add a space.

(+-+) : a -> b -> String
(+-+) a b =

Usage

s : String
s =
	"Goodbye Cruel World!!" +-+ ( 1, 2 ) +-+ { x = [ 3, 4 ], y = "abc" }

This produces the string: Goodbye Cruel World!! (1,2) { x = [3,4], y = "abc" }.

Helper to make concatentation operators with n spaces

concatWithSpaces : Int -> a -> b -> String
concatWithSpaces count a b =

Usage

(+--+) : a -> b -> String
(+--+) =
    concatWithSpaces 2

s : String
s =
	"Goodbye Cruel World!!" +--+ ( 1, 2 ) +--+ { x = [ 3, 4 ], y = "abc" }

This produces the string: Goodbye Cruel World!!  (1,2)  { x = [3,4], y = "abc" }.

Clean elm toString string. Elm creates too many backslashes in it's output and this function will clear those out.

cleanElmString : String -> String
cleanElmString string

Usage

Debug.log "record" (cleanElmString <| toString {a = "aaaaaa", b = "bbbbbb"})

Without cleanElmString, it would print out:

record: "{ a = \"aaaaaa\", b = \"bbbbbb\" }"

With cleanElmString, it prints out:

record: "{ a = "aaaaaa", b = "bbbbbb" }"