FR
PréludeChargé par défaut — aucun import nécessaire.

Show — conversion to String

Synopsis
interface Show a where
show : a -> String
showsPrec : Nat -> a -> String

Convert a value to its String representation.

Two methods, mutually defaulting, so an instance need only give one:

  • show — the everyday "show me this value" (precedence 0).
  • showsPrec d — show at surrounding precedence d, adding parentheses

when the value would otherwise be ambiguous (e.g. a constructor with arguments sitting inside another). By convention function application has precedence 10, so a field of a constructor is shown at 11: that is what makes Just (Just 3) print with the inner parentheses. Hand-written instances of atomic values just give show; the derived Show (and the compound instances below) give showsPrec for faithfulness.

showParen : Bool -> String -> String

Wrap a string in parentheses when the flag is set — the precedence guard used throughout precedence-aware showsPrec.

escStringChar : Char -> String
showDoubleFull : Double -> String
showCommaList : Show a => List a -> String

Comma-separated elements, for showing lists.