[Haskell-beginners] list range
Mike Meyer
mwm at mired.org
Wed Dec 28 21:19:25 CET 2011
On Wed, 28 Dec 2011 19:08:08 +0000
Henry Lockyer <henry.lockyer at ntlworld.com> wrote:
> 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]
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the Beginners
mailing list