Intro to functional dependencies in Haskell?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Intro to functional dependencies in Haskell?

Alexis Hazell
Hi all,

i'm having some trouble 'getting' functional dependencies in the Haskell
context (although my understanding of them in the context of relational
database theory isn't that great either). Could someone please point me
to an introduction / tutorial in this regard?

Thanks!


Alexis.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Intro to functional dependencies in Haskell?

Bulat Ziganshin-2
Hello Alexis,

Thursday, April 17, 2008, 9:21:16 AM, you wrote:

> i'm having some trouble 'getting' functional dependencies in the Haskell

ghc 6.8 manual contains good introduction into FDs

--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Intro to functional dependencies in Haskell?

Marc Weber
In reply to this post by Alexis Hazell
On Thu, Apr 17, 2008 at 03:21:16PM +1000, Alexis Hazell wrote:
> Hi all,
>
> i'm having some trouble 'getting' functional dependencies in the Haskell
> context (although my understanding of them in the context of relational
> database theory isn't that great either). Could someone please point me
> to an introduction / tutorial in this regard?

I think you've already tried www.haskell.org -> wiki search ?
http://haskell.org/haskellwiki/Functional_dependencies

        You can express this by specifying a functional dependency, or fundep for short:

        class Mult a b c | a b -> c where
          (*) :: a -> b -> c

        This tells Haskell that c is uniquely determined from a and b.

So there you can't implement instances
Mult Int Char Sting
        and
Mult Int Char MyString

of course, your programs will work withou t that | a b -> c as well,
but you need to tell the compiler the result type of
(*) fac1 fac2
wheeras using fundeps it knows the result type becaus there can only be
one instance. (Which is what you want in this case when multiplying
matrizes as well.

HTH
Marc Weber
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Intro to functional dependencies in Haskell?

Bugzilla from alfonso.acosta@gmail.com
In reply to this post by Alexis Hazell
Not so long ago, I had difficulties to understand functional dependecies.

Due to the (sometimes well-grounded) prejudgement of considering
research papers as an unfriendly and obscure source of information, I
stupidly ruled out reading Mark P Jones original paper. Then I learned
I was totally wrong, it is written in a friendly way, with lots of
examples, allowing me to finally understand how functional
dependencies work and what was the reason to introduce them:

http://web.cecs.pdx.edu/~mpj/pubs/fundeps.html




On Thu, Apr 17, 2008 at 7:21 AM, Alexis Hazell <[hidden email]> wrote:

> Hi all,
>
>  i'm having some trouble 'getting' functional dependencies in the Haskell
>  context (although my understanding of them in the context of relational
>  database theory isn't that great either). Could someone please point me
>  to an introduction / tutorial in this regard?
>
>  Thanks!
>
>
>  Alexis.
>  _______________________________________________
>  Haskell-Cafe mailing list
>  [hidden email]
>  http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe