How to get the signature of a range function type in Haskell?

Many functions in Haskell that consist of special characters in Haskell are infix functions. These include *, +, ==, /, etc. To get signatures like these functions, you put the function in parentheses and do :t, for example:

GHCi> :t (==)
(==) :: Eq a => a -> a -> Bool

I wanted to try and get the signature of the range function type [a..a], but it seems that this function is infix, but can only be used in a list []. I tried all of the following, but no one worked:

GHCi> :t (..)
<interactive>:1:2: parse error on input `..'
GHCi> :t ([..])
<interactive>:1:3: parse error on input `..'
GHCi> :t [..]
<interactive>:1:2: parse error on input `..'
GHCi> :t ..
<interactive>:1:1: parse error on input `..'

Does anyone know how to get a signature of a range function type?

+5
source share
2 answers

.. , . : enumFrom, enumFromThen, enumFromTo enumFromThenTo.

, , -. :

[1..]     -- enumFrom 1
[1,2..]   -- enumFromThen 1 2
[1..10]   -- enumFromTo 1 10
[1,2..10] -- enumFromThenTo 1 2 10

, .

, 1.. ; . , [1,2..10] [1,(2..10)], , .

Enum, .. , . , [False ..] [False, True]. ( , - [False..], , False .)

+13

.

> :t \x y -> [x..y]

- enumFrom enumFromTo, .

+8

All Articles