Reputation:
What's the naming convention for long data's with multiple constructors? How can I format this?
data MyData =
MyData1
{ var1 :: Int
, var2 :: String
, var3 :: String
, var4 :: String
, var5 :: String
, var6 :: String
, var7 :: String
, var8 :: String
} |
MyData2
{ var1 :: Int
, var2 :: String
, var3 :: String
, var4 :: String
} |
MyData3
{ var3 :: String
, var4 :: String
}
I haven't found anything about this.
UPDATE:
I mean, how can I place the constructors and fields and the "|". One line, different line? What exactly on one line, what on different line?
Upvotes: 0
Views: 140
Reputation: 170723
For formatting, it's commonly recommended to align =
and |
(e.g. https://github.com/chrisdone/haskell-style-guide#data-types and https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md#data-declarations):
data MyData = MyData1
{ var1 :: ...
, var2 :: ...
}
| MyData2 ...
or
data MyData
= MyData1 { var1 :: ...
, var2 :: ...
}
| MyData2 ...
Upvotes: 1
Reputation: 198033
The convention is to use names in normal English that reflect what the data type is actually supposed to mean. What does this data represent? What are the meanings of the fields? What is var1
used to store?
Name your fields after the answer.
Upvotes: 1