KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was doing this type of thing in my code: data MyType = Cons1 a b data OtherType = OtherType { val1 :: Int , val2 :: String , val3 :: Maybe MyType } and I was wondering if changing the code to this would be neater/simpler and what the pros/cons are: data MyType = Cons1 a b | Missing data OtherType = OtherType { val1 :: Int , val2 :: String , val3 :: MyType } What I am doing is reading lines from a file into [OtherType], each line has 4 columns say with columns 3 and 4 being used to create val3 :: MyType. Currently I am using readMaybe to read a and b and then passing them to a function that returns Nothing if either of them are Nothing or Just MyType if they are Just a and Just b. I was thinking I could change this to return Missing instead thereby removing one layer of wrapping.
Tags (comma-separated)
Save Edits
Cancel