On Thu, Dec 27, 2012 at 11:48 PM, Rustom Mody wrote:
> On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh wrote:
>> What he really wants methinks is a way to suppress type classes
altogether! That or a NoOverloadedNumerals extension.
>
> I'm not really sure about that... Look!
>
> Prelude> :t [[1,2],3]
Forgot to say: if you go the first route, you'll also need to define your
fromInteger in every module — the one from .ghci won't be in scope.
You can define
module MyPrelude (module Prelude, fromInteger) where
import Prelude hiding (fromInteger)
fromInteger = id
and import it instead.
*
* Rustom Mody [2012-12-27 22:18:15+0530]
> But now we are in for new surprises: Try out
> f x y = x / y
> Prelude> :l f
> [1 of 1] Compiling Main ( f.hs, interpreted )
>
> f.hs:1:11: Not in scope: `/'
> Failed, modules loaded: none.
> Prelude> (/)
It's because RebindableSyntax impli
I don't know about the RebindableSyntax extension. But
Prelude> :t [[1,2],3]
[[1,2],3] :: (Num [t], Num t) => [[t]]
The above only says that is is possible to have a list like [[1,2],3] if
you have for a Num t, [t] is also an instance of Num. But it doesn't
guarantee the existence of such an ins
On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh wrote:
> Hi David, it looks like Rustom's aware that haskell's not lisp. What he
> really wants methinks is a way to suppress type classes altogether! That or
> a NoOverloadedNumerals extension.
>
> -- Kim-Ee
>
>
I'm not really sure about that... Look!
Hi David, it looks like Rustom's aware that haskell's not lisp. What he
really wants methinks is a way to suppress type classes altogether! That or
a NoOverloadedNumerals extension.
-- Kim-Ee
On Thu, Dec 27, 2012 at 4:03 PM, David Virebayre wrote:
> Prelude> :t [[1,2],3]
>
> you have a list wi
Prelude> :t [[1,2],3]
you have a list with 2 elements:
- [1,2]
- 3
the type of [1,2] is [Integer]
the type of 3 is Integer
But all elements in a list must have the same type.
2012/12/27 Rustom Mody :
>
>
> On Thu, Dec 27, 2012 at 1:48 AM, Roman Cheplyaka wrote:
>>
>> * Rustom Mody [2012-12
On Thu, Dec 27, 2012 at 1:48 AM, Roman Cheplyaka wrote:
> * Rustom Mody [2012-12-26 20:12:17+0530]
> > So is there any set of flags to make haskell literals less polymorphic?
>
> Yes, there is!
>
> % ghci -XRebindableSyntax
> GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help
>
* Rustom Mody [2012-12-26 20:12:17+0530]
> So is there any set of flags to make haskell literals less polymorphic?
Yes, there is!
% ghci -XRebindableSyntax
GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer
Sorry, forgot the link:
http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/interactive-evaluation.html
Section 2.4.5 Type defaulting in GHCi
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
You should note that GHCi uses extended defaulting rules as explained in
[1].
This means that a literal like 5 will only be of type Num a => a in GHCi
while in a normal Haskell program it will default to some concrete type
(Integer if there are no other constraints). Also, if you define x = 5
in a
In haskell, we have
Prelude> :t 4
4 :: Num a => a
Prelude>
This may be nice in its generality but it makes it hard (for me at least)
when teaching a beginners course to teach polymorphic vs monomorphic
types. The above leads to even more 'advanced' results like this:
Prelude> :t [[1],2]
[[1],2]
12 matches
Mail list logo