[Haskell-beginners] how to define records containing finite length lists.

Srikanth K k.srikanth.opensource at gmail.com
Tue Dec 1 12:08:43 EST 2009


Hi,
   I want to define a record say "Student".  The 'C' equvivalent for the
same could be

struct Person {
     char name[10]
     int age }

The closest I can find for doing such a thing in haskell appears to be

data Person = Person{
     name :: [char]
     age :: Int
}

I have not yet been able to find a suitable way to specify the constraint on
the length of list(name in this case).
So can someone let me know how we can impose this length constratint on the
list  and derive a new type.

If standard haskell doesn't give this flexibility, are there any extensions
in ghc to achieve the same.
- Srikanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091201/26f62c2c/attachment.html


More information about the Beginners mailing list