[Haskell-beginners] Use a list as data for a data type?

Bryce Verdier bryceverdier at gmail.com
Fri Feb 22 19:43:32 CET 2013


Lets say I have a data type like so:

data IpAddress = IpAddress {$
          o1 :: !Int,$
          o2 :: !Int,$
          o3 :: !Int,$
          o4 :: !Int$
      } deriving (Show)$

which you can create by doing:
IpAddress 192 168 1 1

Is there a way to do the same thing with the input data in a list? Like:
IpAddress [192,168,1,1]

or using some operator (or combination of operators):Like (I'm guessing 
(<????>) isn't in use):
IpAddress <????> [192,168,1,1]

Thanks in advance,
Bryce



More information about the Beginners mailing list