[Haskell-cafe] Implementing parental using blood type

Francesco Ariis fa-ml at ariis.it
Sun Jun 29 05:05:20 UTC 2014

On Sat, Jun 28, 2014 at 11:16:31PM -0300, Rafael Almeida wrote:
> I'm trying to practice my Haskell. So I had the idea of making a program
> which, given a mother's and a child blood type, it can determine whether a
> certain father is possible or not.
> Please take a look on this gist with my implementation:
>     https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting
> Would you care to comment on it? It looks a bit cumbersome to my eyes. I'm
> trying to find the most intuitive and elegant way of do it. I'm not so much
> worried with performance.

Since your 'main' function returns a Bool (possible/impossible), a simpler
way to approach the problem is to calculate the potential blood-type of child
C given parents A and B and then check the actual blood-type passed against
this list (I attach a .hs with such solution).

The 'cumbersome' part is the |Genes -> BloodType| conversion (and vice-versa);
you can calculate the inverse instead of typing it out, but it will still be

-------------- next part --------------
A non-text attachment was scrubbed...
Name: parentaltesting.hs
Type: text/x-haskell
Size: 889 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140629/4a62ba52/attachment.hs>

More information about the Haskell-Cafe mailing list