Changes between Initial Version and Version 1 of Ticket #1696


Ignore:
Timestamp:
Sep 14, 2007 10:08:19 PM (7 years ago)
Author:
simonpj
Comment:

Was the type of (^) declared by you with a type signature, or inferred?

Simon

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1696 – Description

    initial v1  
    11I was working with some buggy numerical code of mine, and I was having problems with some types involving exponentiation. My working hypothesis was that the problem involved using ^ with a numerical type I had defined - I had checked ^'s type through :t and saw: 
    2  
     2{{{ 
    33 (^) :: forall a b. (Integral b, Num a) => a -> b -> a 
    4  
     4}}} 
    55I immediately thought that I needed another type class declaration for my new type, and went haring off on that tangent for a long time. Eventually someone on #haskell pointed out to me that the *base* could be Num, but the power to which it was being raised had to be Integral and that my problems stemmed from going foo^(1/3), and that what I needed was more along the lines of foo**(1/3).  
    66 
    77My confusion stemmed from the variables - the forall declaration goes, in order, a-b, and the curried signature itself goes a-b as well, but the classes goes b-a! This apparently is for no particular reason, and so I think it'd be good if the signatures :t displayed could be a little more consistent and go a-b as well, so it'd be instead: 
    8  
     8{{{ 
    99 (^) :: forall a b. (Num a, Integral b) => a -> b -> a 
    10  
     10}}} 
    1111A small thing, perhaps, but it did trip me up.