Classes and Instances to convert values to Strings (Show.show) and Strings to values ("read").
There are a few differences to Haskell, notably
Haskell compatibility
Haskell compatibility
Class Show provides operations to convert values to Strings.
This class can be derived for all algebraic data types whose constituents are themselves instances of Show.
Bool, (), (,), (,,), Int, Char, Lang.Byte, Either, Double, Float, StringJ, Ordering, Long, Integer, Maybe, Lang.Short, Regex, [], Throwable
Show.display computes an alternate string representation of a value and is used in the Char and String instances of Show to produce an unquoted string.
The default implementation is to do the same as Show.show.
Computes the string representation of a value.
Every instance must implement Show.show.
Show.showChars addresses the problem of Show.showing infinite values. Because Show.show has type String and String is atomic, this would try to create a string with infinite length, and hence is doomed to fail.
The default definition is
showChars = String.toList . show
This is ok for all finite values. But instances for recursive types should implement it in a way that produces a lazy list of characters.
Here is an example for the list instance:
showChars [] = ['[', ']'] showChars xs = '[' : ( tail [ c | x <- xs, c <- ',' : showChars x ] ++ [']'] )
Haskell compatibility
Haskell compatibility
Show.showsub is used for Show.showing elements of a value of an algebraic data type in derived instances of Show.
The generated code in derived instances for types that are not enumerations is
showsub x = "(" ++ show x ++ ")"
so that values are enclosed in parentheses. Certain types like records, lists, tuples and many primitive types do not need extra parentheses, and thus Show.showsub is the same as Show.show, which is also the default implementation.
In short,
Example:
derive Show ( Maybe b)
implements the following:
show Nothing = "Nothing" show (Just x) = "Just " ++ x.showsub showsub x = "(" ++ show x ++ ")"
so that
show (Just (Just 42)) == "Just (Just 42)"
joined sep xs concatenates all strings in /xs/, and inserts /sep/ between any two elements of /xs/.
If /xs/ is empty, the result is an empty string. If /sep/ is an empty string, then the result is just the concatenation of the strings in /xs/.
Example:
joined ", " ["aaa", "bbb", "ccc"] == "aaa, bbb, ccc"
convert a list of characters to a string
packed ['a', 'b', 'c' ] == "abc"
Haskell compatibility
Haskell compatibility
Haskell compatibility
Haskell compatibility
Preliminary substitute for Read
splits a String on end-of-line and returns a list of Strings
The last line may or may not be terminated by newline.
End-of-line is signaled by a number of carriage returns followed by a new line.
This should work for UNIX and Windows.
The line separator suitable for the platform the program is running on.
unlines is an inverse operation to lines.
It joins lines, after appending a terminating newline to each.
strip trailing spaces, tabs, newline and carriage return characters from a string
splits a String on non empty sequences of spaces and returns a list of Strings
Since this uses java.util.Regex.split the result will start with an empty string if the argument starts with spaces. This is a difference to words, which, according to the Haskell standard, does not include the empty string.
splits a String on non empty sequences of spaces and returns a list of non-empty Strings
unwords is an inverse operation to words.
It joins words with separating spaces.
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
Function generated for derived instance.
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
construct a string that consists of just this character
reconstructs a Java char literal from a character, i.e.
show 'a' = "'a'"
inherited from Show.showChars
the string created from the characters
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
Function generated for derived instance.
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
the String representation of the Int argument, uses java.lang.String.valueOf
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
the String representation of the Integer argument, uses BigInteger.toString
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
the String representation of the Long argument, uses java.lang.Long.toString
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
Function generated for derived instance.
inherited from Show.display
Function generated for derived instance.
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
Function generated for derived instance.
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
reconstructs a Java string literal from a string, i.e.
show "abc" = "\"abc\""
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
creates a string representation of a Java exception, consisting of the class name and the message, like
"java.lang.ArithmeticException: division by zero"
inherited from Show.showChars
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
inherited from Show.display
inherited from Show.showList
inherited from Show.showsPrec
inherited from Show.showsub
chomp, Show_String.showsub, Show_String.display, Show_String.show
Show_Integer.showsub, Show_Integer.display, Show_Integer.show
Show_Ordering.showsub, Show_Ordering.display, Show_Ordering.show
Show_Throwable.showsub, Show_Throwable.display, Show_Throwable.show