Module Prelude.PreludeText

Classes and Instances to convert values to Strings (Show.show) and Strings to values ("read").

There are a few differences to Haskell, notably

Imports

Table of Content

Definitions

type ShowS = StringJ Char → StringJ Char

Haskell compatibility

type ReadS a = StringJ Char → [(a, StringJ Char)]

Haskell compatibility

class Show show

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.

Known Instances

Bool, (), (,), (,,), Int, Char, Lang.Byte, Either, Double, Float, StringJ, Ordering, Long, Integer, Maybe, Lang.Short, Regex, [], Throwable

Member Functions

display ∷ Show show ⇒ show → String

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.

show ∷ Show show ⇒ show → String

Computes the string representation of a value.

Every instance must implement Show.show.

showChars ∷ Show show ⇒ show → [Char]

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 ] ++ [']'] )
showList ∷ Show show ⇒ [show] → String → String

Haskell compatibility

showsPrec ∷ Show show ⇒ Int → show → String → String

Haskell compatibility

showsub ∷ Show show ⇒ show → String

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 ∷ String → [String] → String

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"
packed ∷ [Char] → String

convert a list of characters to a string

 packed ['a', 'b', 'c' ] == "abc"
shows ∷ Show a ⇒ a → String → String

Haskell compatibility

showChar ∷ Char → String → String

Haskell compatibility

showString ∷ String → String → String

Haskell compatibility

showParen ∷ Bool → (String → String) → String → String

Haskell compatibility

class Read a

Preliminary substitute for Read

Known Instances

Int

Member Functions

read ∷ Read a ⇒ String → a
lines ∷ String → [String]

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.

lineSeparator ∷ String

The line separator suitable for the platform the program is running on.

unlines ∷ [String] → String

unlines is an inverse operation to lines.

It joins lines, after appending a terminating newline to each.

chomp ∷ String → String

strip trailing spaces, tabs, newline and carriage return characters from a string

splittedWords ∷ String → [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.

words ∷ String → [String]

splits a String on non empty sequences of spaces and returns a list of non-empty Strings

unwords ∷ [String] → String

unwords is an inverse operation to words.

It joins words with separating spaces.

Instances

instance Read Int

Member Functions

read ∷ String → Int
instance Show ()

Member Functions

display ∷ () → String

inherited from Show.display

show ∷ () → String

Function generated for derived instance.

showChars ∷ () → [Char]

inherited from Show.showChars

showList ∷ [()] → String → String

inherited from Show.showList

showsPrec ∷ Int → () → String → String

inherited from Show.showsPrec

showsub ∷ () → String

Function generated for derived instance.

instance (Show a, Show b) ⇒ Show (a, b)

Member Functions

display ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → String

inherited from Show.display

show ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → String

Function generated for derived instance.

showChars ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → [Char]

inherited from Show.showChars

showList ∷ (Show 𝖇, Show 𝖆) ⇒ [(𝖇, 𝖆)] → String → String

inherited from Show.showList

showsPrec ∷ (Show 𝖇, Show 𝖆) ⇒ Int → (𝖇, 𝖆) → String → String

inherited from Show.showsPrec

showsub ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → String

inherited from Show.showsub

instance (Show a, Show b, Show c) ⇒ Show (a, b, c)

Member Functions

display ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → String

inherited from Show.display

show ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → String

Function generated for derived instance.

showChars ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → [Char]

inherited from Show.showChars

showList ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ [(𝖇, 𝖈, 𝖆)] → String → String

inherited from Show.showList

showsPrec ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ Int → (𝖇, 𝖈, 𝖆) → String → String

inherited from Show.showsPrec

showsub ∷ (Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → String

inherited from Show.showsub

instance Show Bool

Member Functions

display ∷ Bool → String

inherited from Show.display

show ∷ Bool → String
showChars ∷ Bool → [Char]

inherited from Show.showChars

showList ∷ [Bool] → String → String

inherited from Show.showList

showsPrec ∷ Int → Bool → String → String

inherited from Show.showsPrec

showsub ∷ Bool → String

inherited from Show.showsub

instance Show Byte

Member Functions

display ∷ Byte → String

inherited from Show.display

show ∷ Byte → String
showChars ∷ Byte → [Char]

inherited from Show.showChars

showList ∷ [Byte] → String → String

inherited from Show.showList

showsPrec ∷ Int → Byte → String → String

inherited from Show.showsPrec

showsub ∷ Byte → String

inherited from Show.showsub

instance Show Char

Member Functions

display ∷ Char → String

construct a string that consists of just this character

show ∷ Char → String
pure native frege.runtime.Runtime.quoteChr

reconstructs a Java char literal from a character, i.e.

 show 'a' = "'a'"   
showChars ∷ Char → [Char]

inherited from Show.showChars

showList ∷ [Char] → String → String

the string created from the characters

showsPrec ∷ Int → Char → String → String

inherited from Show.showsPrec

showsub ∷ Char → String

inherited from Show.showsub

instance Show Double

Member Functions

display ∷ Double → String

inherited from Show.display

show ∷ Double → String
pure native java.lang.Double.toString
showChars ∷ Double → [Char]

inherited from Show.showChars

showList ∷ [Double] → String → String

inherited from Show.showList

showsPrec ∷ Int → Double → String → String

inherited from Show.showsPrec

showsub ∷ Double → String

inherited from Show.showsub

instance (Show a, Show b) ⇒ Show (a | b)

Member Functions

display ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → String

inherited from Show.display

show ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → String

Function generated for derived instance.

showChars ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → [Char]

inherited from Show.showChars

showList ∷ (Show 𝖇, Show 𝖆) ⇒ [(𝖇 | 𝖆)] → String → String

inherited from Show.showList

showsPrec ∷ (Show 𝖇, Show 𝖆) ⇒ Int → (𝖇 | 𝖆) → String → String

inherited from Show.showsPrec

showsub ∷ (Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → String

Function generated for derived instance.

instance Show Float

Member Functions

display ∷ Float → String

inherited from Show.display

show ∷ Float → String
pure native java.lang.Float.toString
showChars ∷ Float → [Char]

inherited from Show.showChars

showList ∷ [Float] → String → String

inherited from Show.showList

showsPrec ∷ Int → Float → String → String

inherited from Show.showsPrec

showsub ∷ Float → String

inherited from Show.showsub

instance Show Int

Member Functions

display ∷ Int → String

inherited from Show.display

show ∷ Int → String
pure native java.lang.String.valueOf

the String representation of the Int argument, uses java.lang.String.valueOf

showChars ∷ Int → [Char]

inherited from Show.showChars

showList ∷ [Int] → String → String

inherited from Show.showList

showsPrec ∷ Int → Int → String → String

inherited from Show.showsPrec

showsub ∷ Int → String

inherited from Show.showsub

instance Show Integer

Member Functions

display ∷ Integer → String

inherited from Show.display

show ∷ Integer → String
pure native toString

the String representation of the Integer argument, uses BigInteger.toString

showChars ∷ Integer → [Char]

inherited from Show.showChars

showList ∷ [Integer] → String → String

inherited from Show.showList

showsPrec ∷ Int → Integer → String → String

inherited from Show.showsPrec

showsub ∷ Integer → String

inherited from Show.showsub

instance Show Long

Member Functions

display ∷ Long → String

inherited from Show.display

show ∷ Long → String
pure native java.lang.Long.toString

the String representation of the Long argument, uses java.lang.Long.toString

showChars ∷ Long → [Char]

inherited from Show.showChars

showList ∷ [Long] → String → String

inherited from Show.showList

showsPrec ∷ Int → Long → String → String

inherited from Show.showsPrec

showsub ∷ Long → String

inherited from Show.showsub

instance Show a ⇒ Show (Maybe a)

Member Functions

display ∷ Show 𝖆 ⇒ Maybe 𝖆 → String

inherited from Show.display

show ∷ Show 𝖆 ⇒ Maybe 𝖆 → String

Function generated for derived instance.

showChars ∷ Show 𝖆 ⇒ Maybe 𝖆 → [Char]

inherited from Show.showChars

showList ∷ Show 𝖆 ⇒ [Maybe 𝖆] → String → String

inherited from Show.showList

showsPrec ∷ Show 𝖆 ⇒ Int → Maybe 𝖆 → String → String

inherited from Show.showsPrec

showsub ∷ Show 𝖆 ⇒ Maybe 𝖆 → String

Function generated for derived instance.

instance Show Ordering

Member Functions

display ∷ Ordering → String

inherited from Show.display

show ∷ Ordering → String

Function generated for derived instance.

showChars ∷ Ordering → [Char]

inherited from Show.showChars

showList ∷ [Ordering] → String → String

inherited from Show.showList

showsPrec ∷ Int → Ordering → String → String

inherited from Show.showsPrec

showsub ∷ Ordering → String

Function generated for derived instance.

instance Show Regex

Member Functions

display ∷ Regex → String

inherited from Show.display

show ∷ Regex → String
showChars ∷ Regex → [Char]

inherited from Show.showChars

showList ∷ [Regex] → String → String

inherited from Show.showList

showsPrec ∷ Int → Regex → String → String

inherited from Show.showsPrec

showsub ∷ Regex → String

inherited from Show.showsub

instance Show Short

Member Functions

display ∷ Short → String

inherited from Show.display

show ∷ Short → String
showChars ∷ Short → [Char]

inherited from Show.showChars

showList ∷ [Short] → String → String

inherited from Show.showList

showsPrec ∷ Int → Short → String → String

inherited from Show.showsPrec

showsub ∷ Short → String

inherited from Show.showsub

instance Show String

Member Functions

display ∷ String → String
show ∷ String → String
pure native frege.runtime.Runtime.quoteStr

reconstructs a Java string literal from a string, i.e.

 show "abc" = "\"abc\""   
showChars ∷ String → [Char]

inherited from Show.showChars

showList ∷ [String] → String → String

inherited from Show.showList

showsPrec ∷ Int → String → String → String

inherited from Show.showsPrec

showsub ∷ String → String

inherited from Show.showsub

instance Show Throwable

Member Functions

display ∷ Throwable → String

inherited from Show.display

show ∷ Throwable → String

creates a string representation of a Java exception, consisting of the class name and the message, like

 "java.lang.ArithmeticException: division by zero"
showChars ∷ Throwable → [Char]

inherited from Show.showChars

showList ∷ [Throwable] → String → String

inherited from Show.showList

showsPrec ∷ Int → Throwable → String → String

inherited from Show.showsPrec

showsub ∷ Throwable → String

inherited from Show.showsub

instance Show a ⇒ Show [a]

Member Functions

display ∷ Show 𝖆 ⇒ [𝖆] → String

inherited from Show.display

show ∷ Show 𝖆 ⇒ [𝖆] → String
showChars ∷ Show 𝖆 ⇒ [𝖆] → [Char]
showList ∷ Show 𝖆 ⇒ [[𝖆]] → String → String

inherited from Show.showList

showsPrec ∷ Show 𝖆 ⇒ Int → [𝖆] → String → String

inherited from Show.showsPrec

showsub ∷ Show 𝖆 ⇒ [𝖆] → String

inherited from Show.showsub

Functions and Values by Type

String → String → String

showString

String → [String] → String

joined

String → String

chomp, Show_String.showsub, Show_String.display, Show_String.show

String → [String]

lines, splittedWords, words

String → [Char]

Show_String.showChars

String → Int

Read_Int.read

[String] → String → String

Show_String.showList

[String] → String

unlines, unwords

[Byte] → String → String

Show_Byte.showList

[Short] → String → String

Show_Short.showList

[Regex] → String → String

Show_Regex.showList

[()] → String → String

Show_().showList

[Bool] → String → String

Show_Bool.showList

[Char] → String → String

Show_Char.showList

[Char] → String

packed

[Double] → String → String

Show_Double.showList

[Float] → String → String

Show_Float.showList

[Int] → String → String

Show_Int.showList

[Integer] → String → String

Show_Integer.showList

[Long] → String → String

Show_Long.showList

[Ordering] → String → String

Show_Ordering.showList

[Throwable] → String → String

Show_Throwable.showList

Byte → String

Show_Byte.showsub, Show_Byte.display, Show_Byte.show

Byte → [Char]

Show_Byte.showChars

Short → String

Show_Short.showsub, Show_Short.display, Show_Short.show

Short → [Char]

Show_Short.showChars

Regex → String

Show_Regex.showsub, Show_Regex.display, Show_Regex.show

Regex → [Char]

Show_Regex.showChars

() → String

Show_().showsub, Show_().display, Show_().show

() → [Char]

Show_().showChars

Bool → (String → String) → String → String

showParen

Bool → String

Show_Bool.showsub, Show_Bool.display, Show_Bool.show

Bool → [Char]

Show_Bool.showChars

Char → String → String

showChar

Char → String

Show_Char.showsub, Show_Char.display, Show_Char.show

Char → [Char]

Show_Char.showChars

Double → String

Show_Double.showsub, Show_Double.display, Show_Double.show

Double → [Char]

Show_Double.showChars

Float → String

Show_Float.showsub, Show_Float.display, Show_Float.show

Float → [Char]

Show_Float.showChars

Int → String → String → String

Show_String.showsPrec

Int → Byte → String → String

Show_Byte.showsPrec

Int → Short → String → String

Show_Short.showsPrec

Int → Regex → String → String

Show_Regex.showsPrec

Int → () → String → String

Show_().showsPrec

Int → Bool → String → String

Show_Bool.showsPrec

Int → Char → String → String

Show_Char.showsPrec

Int → Double → String → String

Show_Double.showsPrec

Int → Float → String → String

Show_Float.showsPrec

Int → Int → String → String

Show_Int.showsPrec

Int → Integer → String → String

Show_Integer.showsPrec

Int → Long → String → String

Show_Long.showsPrec

Int → Ordering → String → String

Show_Ordering.showsPrec

Int → Throwable → String → String

Show_Throwable.showsPrec

Int → String

Show_Int.showsub, Show_Int.display, Show_Int.show

Int → [Char]

Show_Int.showChars

Integer → String

Show_Integer.showsub, Show_Integer.display, Show_Integer.show

Integer → [Char]

Show_Integer.showChars

Long → String

Show_Long.showsub, Show_Long.display, Show_Long.show

Long → [Char]

Show_Long.showChars

Ordering → String

Show_Ordering.showsub, Show_Ordering.display, Show_Ordering.show

Ordering → [Char]

Show_Ordering.showChars

Throwable → String

Show_Throwable.showsub, Show_Throwable.display, Show_Throwable.show

Throwable → [Char]

Show_Throwable.showChars

String

lineSeparator

Read a ⇒ String → a

Read.read

Show a ⇒ a → String → String

shows

Show show ⇒ [show] → String → String

Show.showList

Show show ⇒ Int → show → String → String

Show.showsPrec

Show show ⇒ show → String

Show.showsub, Show.display, Show.show

Show show ⇒ show → [Char]

Show.showChars

Show 𝖆 ⇒ Maybe 𝖆 → String

Show_Maybe.showsub, Show_Maybe.display, Show_Maybe.show

Show 𝖆 ⇒ Maybe 𝖆 → [Char]

Show_Maybe.showChars

Show 𝖆 ⇒ [Maybe 𝖆] → String → String

Show_Maybe.showList

Show 𝖆 ⇒ [[𝖆]] → String → String

Show_[].showList

Show 𝖆 ⇒ [𝖆] → String

Show_[].showsub, Show_[].display, Show_[].show

Show 𝖆 ⇒ [𝖆] → [Char]

Show_[].showChars

Show 𝖆 ⇒ Int → Maybe 𝖆 → String → String

Show_Maybe.showsPrec

Show 𝖆 ⇒ Int → [𝖆] → String → String

Show_[].showsPrec

(Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → String

Show_(,).showsub, Show_(,).display, Show_(,).show

(Show 𝖇, Show 𝖆) ⇒ (𝖇, 𝖆) → [Char]

Show_(,).showChars

(Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → String

Show_Either.showsub, Show_Either.display, Show_Either.show

(Show 𝖇, Show 𝖆) ⇒ (𝖇 | 𝖆) → [Char]

Show_Either.showChars

(Show 𝖇, Show 𝖆) ⇒ [(𝖇, 𝖆)] → String → String

Show_(,).showList

(Show 𝖇, Show 𝖆) ⇒ [(𝖇 | 𝖆)] → String → String

Show_Either.showList

(Show 𝖇, Show 𝖆) ⇒ Int → (𝖇, 𝖆) → String → String

Show_(,).showsPrec

(Show 𝖇, Show 𝖆) ⇒ Int → (𝖇 | 𝖆) → String → String

Show_Either.showsPrec

(Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → String

Show_(,,).showsub, Show_(,,).display, Show_(,,).show

(Show 𝖇, Show 𝖈, Show 𝖆) ⇒ (𝖇, 𝖈, 𝖆) → [Char]

Show_(,,).showChars

(Show 𝖇, Show 𝖈, Show 𝖆) ⇒ [(𝖇, 𝖈, 𝖆)] → String → String

Show_(,,).showList

(Show 𝖇, Show 𝖈, Show 𝖆) ⇒ Int → (𝖇, 𝖈, 𝖆) → String → String

Show_(,,).showsPrec

Valid HTML 4.01 Strict