
Hi Is list range (for example: [1..10]) a language construct or a function? What type does it have? -- This e-mail address is invalid, see: http://people.eisenbits.com/~stf/public-email-note.html . OpenPGP: E3D9 C030 88F5 D254 434C 6683 17DD 22A0 8A3B 5CC0

I'm a beginner so beware, but I believe [1..10] is a VALUE (it is not a function from something to something else). It's type is essentially 'list of numeric' but because you used "..." to express a range of values it also has to be of type 'Enum' as well as numeric. If you have GHCI installed, then I recommend using the ":t" command to explore the types of Haskell expressions. / Henry On 28 Dec 2011, at 18:51, Stanisław Findeisen wrote:
Hi
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
-- This e-mail address is invalid, see: http://people.eisenbits.com/~stf/public-email-note.html .
OpenPGP: E3D9 C030 88F5 D254 434C 6683 17DD 22A0 8A3B 5CC0
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Sorry, should have read your question a second time instead of posting a quick reply ;-) I think it is syntactic sugar.. On 28 Dec 2011, at 19:05, Henry Lockyer wrote:
I'm a beginner so beware, but I believe [1..10] is a VALUE (it is not a function from something to something else). It's type is essentially 'list of numeric' but because you used "..." to express a range of values it also has to be of type 'Enum' as well as numeric. If you have GHCI installed, then I recommend using the ":t" command to explore the types of Haskell expressions. / Henry
On 28 Dec 2011, at 18:51, Stanisław Findeisen wrote:
Hi
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
-- This e-mail address is invalid, see: http://people.eisenbits.com/~stf/public-email-note.html .
OpenPGP: E3D9 C030 88F5 D254 434C 6683 17DD 22A0 8A3B 5CC0
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hi again Stanislaw, since I started digging in this hole.. Having just checked "enum" in the prelude there are a number of functions such as "enumFrom", "enumFromThen", "enumFromTo" etc. that the list range notation syntactic sugar is converted to. /Henry On 28 Dec 2011, at 19:08, Henry Lockyer wrote:
Sorry, should have read your question a second time instead of posting a quick reply ;-) I think it is syntactic sugar..
On 28 Dec 2011, at 19:05, Henry Lockyer wrote:
I'm a beginner so beware, but I believe [1..10] is a VALUE (it is not a function from something to something else). It's type is essentially 'list of numeric' but because you used "..." to express a range of values it also has to be of type 'Enum' as well as numeric. If you have GHCI installed, then I recommend using the ":t" command to explore the types of Haskell expressions. / Henry
On 28 Dec 2011, at 18:51, Stanisław Findeisen wrote:
Hi
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
-- This e-mail address is invalid, see: http://people.eisenbits.com/~stf/public-email-note.html .
OpenPGP: E3D9 C030 88F5 D254 434C 6683 17DD 22A0 8A3B 5CC0
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Wed, 28 Dec 2011 19:08:08 +0000
Henry Lockyer
On 28 Dec 2011, at 19:05, Henry Lockyer wrote: Sorry, should have read your question a second time instead of posting a quick reply ;-) I think it is syntactic sugar..
Others say it's syntactic sugar, but your advice:
If you have GHCI installed, then I recommend using the ":t" command to explore the types of Haskell expressions.
is still good, *and* can answer that question:
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
If it's a function, then :t will know about it, even in that odd
form if you wrap it in parens. For instance:
*Main> :t (+)
(+) :: Num a => a -> a -> a
even if it's a constructor, like:
*Main> :t ((,))
((,)) :: a -> b -> (a, b)
But trying the [..] notation, you get:
*Main Network.HTTP> :t ([..])
<interactive>:1:3: parse error on input `..'
I.e. - it's syntactic sugar to generate a value. If it were a
function, the type would be something like:
([..]) :: Enum a => a -> a -> [a]

On Wed, Dec 28, 2011 at 07:51:35PM +0100, Stanisław Findeisen wrote:
Hi
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
[a .. b] is syntactic sugar which is translated into a call to the function 'enumFromTo': Prelude> [1 .. 10] [1,2,3,4,5,6,7,8,9,10] Prelude> enumFromTo 1 10 [1,2,3,4,5,6,7,8,9,10] -Brent

On Wed, Dec 28, 2011 at 07:51:35PM +0100, Stanisław Findeisen wrote:
Hi
Is list range (for example: [1..10]) a language construct or a function? What type does it have?
[ 1 .. 10 ] is syntatic sugar for the function application enumFromTo 1 10 enumFromTo is a method of the class Enum. Its type is enumFromTo :: Enum a => a -> a -> [a] There is also enumFrom, enumFromThen and enumFromThenTo. Romildo
participants (5)
-
Brent Yorgey
-
Henry Lockyer
-
José Romildo Malaquias
-
Mike Meyer
-
Stanisław Findeisen