[Haskell-cafe] Re: Type question in instance of a class

Reiner Pope reiner.pope at gmail.com
Tue Nov 18 04:38:10 EST 2008


ATs are "Associated Types", aka Type Families. They can be found in
the GHC 6.10 manual here:
http://haskell.org/ghc/docs/6.10.1/html/users_guide/type-families.html

As a starting point, you might want to try something like:

class Complex c where
   type RealType c
   realPart :: c -> RealType c
   imagPart :: c -> RealType c


Cheers,
Reiner

On Tue, Nov 18, 2008 at 7:01 PM, Maurí­cio <briqueabraque at yahoo.com> wrote:
>>  >> (...) One way to code this would be to use functional dependencies:
>>  >>
>>  >> class MyClass r s | r -> s where function :: r -> s
>>
>>> One additional  problem is that I  (believe I) need that  my class takes
>>> just  one type
>>
>> FDs with just one type parameter are called ATs :)
>>
>> (FDs = functional dependencies, ATs is a new feature of ghc 6.8/6.10)
>
>
> Sorry for asking, but I tried to read 6.10 extension documentation
> in user's guide, as well as release notes for 6.10 and 6.8, and
> could not figure out what exactly are ATs. Can you give me a direction?
>
> Thanks,
> Maurício
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list