Answer by Carcigenicate for Retrieve values from datatype
You could also use record syntax to generate accessor functions for the fields:data Node = Node { nodeId :: Integer, children :: [Node] } deriving (Show)[n | n <- nodes, nodeId n == 0]Although this...
View ArticleAnswer by amalloy for Retrieve values from datatype
The only way to get values out of a data constructor is indeed to pattern-match on it. If you want, you can define a function that does it, as you have done with nodeId, or you can just do the pattern...
View ArticleRetrieve values from datatype
I'm trying to implement an object graph in Haskell, and I have a simple Node type which contains a identifier and a list of connected nodes.data Node = Node Integer [Node] deriving (Show)My problem is...
View Article