HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleterminfo-0.4.1.7Haskell2010

System.Console.Terminfo.Base

This module provides a low-level interface to the C functions of the terminfo library.

NOTE: Since this library is built on top of the curses interface, it is not thread-safe.

  • 5 types
  • 3 classes
  • 13 values
  • Packageterminfo-0.4.1.7
  • Exports21
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBase.hs

Initialization

4 declarations
newtypenewtype Terminal
#

Terminal objects are automatically freed by the garbage collector. Hence, there is no equivalent of del_curterm here.

valuesetupTerm :: String -> IO Terminal
#

Initialize the terminfo library to the given terminal entry.

Throws a SetupTermError if the terminfo database could not be read.

  • Note:* ncurses is not thread-safe; initializing or using multiple Terminals in different threads at the same time can result in memory unsafety.

Initialize the terminfo library, using the TERM environmental variable. If TERM is not set, we use the generic, minimal entry dumb.

Throws a SetupTermError if the terminfo database could not be read.

Capabilities

6 declarations
newtypenewtype Capability a
#

A feature or operation which a Terminal may define.

Instances5Monad, Functor, Applicative, Alternative, MonadPlus

Output

3 declarations

Terminfo contains many string capabilities for special effects. For example, the cuu1 capability moves the cursor up one line; on ANSI terminals this is accomplished by printing the control sequence "\ESC[A". However, some older terminals also require "padding", or short pauses, after certain commands. For example, when TERM=vt100 the cuu1 capability is "\ESC[A$<2>", which instructs terminfo to pause for two milliseconds after outputting the control sequence.

The TermOutput monoid abstracts away all padding and control sequence output. Unfortunately, that datatype is difficult to integrate into existing String-based APIs such as pretty-printers. Thus, as a workaround, tiGetOutput1 also lets us access the control sequences as Strings. The one caveat is that it will not allow you to access padded control sequences as Strings. For example:

> t <- setupTerm "vt100"
> isJust (getCapability t (tiGetOutput1 "cuu1") :: Maybe String)
False
> isJust (getCapability t (tiGetOutput1 "cuu1") :: Maybe TermOutput)
True

String capabilities will work with software-based terminal types such as xterm and linux. However, you should use TermOutput if compatibility with older terminals is important. Additionally, the visualBell capability which flashes the screen usually produces its effect with a padding directive, so it will only work with TermOutput.

valuetiGetOutput1 :: OutputCap f => String -> Capability f
#

Look up an output capability which takes a fixed number of parameters (for example, Int -> Int -> TermOutput).

For capabilities which may contain variable-length padding, use tiGetOutput instead.

TermOutput

newtypenewtype TermOutput
#

An action which sends output to the terminal. That output may mix plain text with control characters and escape sequences, along with delays (called "padding") required by some older terminals.

Instances4Semigroup, Monoid, OutputCap, TermStr
typetype LinesAffected = Int
#

A parameter to specify the number of lines affected. Some capabilities (e.g., clear and dch1) use this parameter on some terminals to compute variable-length padding.

Monoid functions

classclass Semigroup a => Monoid a where
#

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:

Right identity

x <> mempty = x

Left identity

mempty <> x = x

Associativity

x <> (y <> z) = (x <> y) <> z

(

Semigroup

law)

Concatenation

mconcat = foldr (<>) mempty

You can alternatively define mconcat instead of mempty, in which case the laws are:

Unit

mconcat (pure x) = x

Multiplication

mconcat (join xss) = mconcat (fmap mconcat xss)

Subclass

mconcat (toList xs) = sconcat xs

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Data.Semigroup.Sum and Data.Semigroup.Product.

NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

Methods

  • mempty :: a

    Identity of mappend

    Examples
    Example1 expression
    "Hello world" <> mempty"Hello world"
    Example1 expression
    mempty <> [1, 2, 3][1,2,3]
  • mappend :: a -> a -> a

    An associative operation

    NOTE: This method is redundant and has the default implementation mappend = (<>) since base-4.11.0.0. Should it be implemented manually, since mappend is a synonym for (<>), it is expected that the two functions are defined the same way. In a future GHC release mappend will be removed from Monoid.

  • mconcat :: [a] -> a

    Fold a list using the monoid.

    For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

    Example1 expression
    mconcat ["Hello", " ", "Haskell", "!"]"Hello Haskell!"
Instances56Monoid, …
  • Monoid ByteArrayDefined in base-4.20.2.0 · Data.Array.Byte
  • Monoid AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid EventDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid EventLifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types
  • Monoid LifetimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Event.Internal.Types

    mappend takes the longer of two lifetimes.

  • Monoid ExceptionContextDefined in ghc-internal-9.1003.0 · GHC.Internal.Exception.Context
  • Monoid OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid TermOutputDefined in terminfo-0.4.1.7 · System.Console.Terminfo.Base
  • Monoid ()Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (Comparison a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on comparisons always returns EQ. Without newtypes this equals pure (pure EQ).

    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ
    
  • Monoid (Equivalence a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on equivalences always returns True. Without newtypes this equals pure (pure True).

    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True
    
  • Monoid (Predicate a)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty on predicates always returns True. Without newtypes this equals pure True.

    mempty :: Predicate a
    mempty = _ -> True
    
  • Monoid (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • Monoid (Endo a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monoid a => Monoid (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Identity
  • Monoid a => Monoid (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Ord
  • Monoid a => Monoid (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid a => Monoid (IO a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid a => Monoid (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid m => Monoid (WrappedMonoid m)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid p => Monoid (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Semigroup a => Monoid (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base

    Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S."

    Since 4.11.0: constraint on inner a value generalised from Monoid to Semigroup.

  • Bits a => Monoid (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • Bits a => Monoid (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits
  • FiniteBits a => Monoid (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • FiniteBits a => Monoid (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Bits

    This constraint is arguably too strong. However, as some types (such as Natural) have undefined complement, this is the only safe choice.

  • Num a => Monoid (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Num a => Monoid (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Ord a => Monoid (Max a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • Ord a => Monoid (Min a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Utils
  • (Generic a, Monoid (Rep a ())) => Monoid (Generically a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Ord a, Bounded a) => Monoid (Max a)Defined in base-4.20.2.0 · Data.Semigroup
  • (Ord a, Bounded a) => Monoid (Min a)Defined in base-4.20.2.0 · Data.Semigroup
  • Monoid (Proxy s)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Proxy
  • Monoid (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Op a b)Defined in base-4.20.2.0 · Data.Functor.Contravariant

    mempty @(Op a b) without newtypes is mempty @(b->a) = _ -> mempty.

    mempty :: Op a b
    mempty = Op _ -> mempty
    
  • Monoid a => Monoid (ST s a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ST
  • Monoid b => Monoid (a -> b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • (Monoid a, Monoid b) => Monoid (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Alternative f => Monoid (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.Internal
  • Monoid (f p) => Monoid (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid a => Monoid (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.Const
  • (Applicative f, Monoid a) => Monoid (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Monoid
  • (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid c => Monoid (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid (f a), Monoid (g a)) => Monoid (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product
  • (Monoid (f p), Monoid (g p)) => Monoid ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base
  • Monoid (f (g a)) => Monoid (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose
  • Monoid (f (g p)) => Monoid ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • Monoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics
  • (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Base