Quantcast
Channel: Retrieve values from datatype - Stack Overflow
Browsing all 3 articles
Browse latest View live

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 Article



Answer 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 Article

Retrieve 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
Browsing all 3 articles
Browse latest View live


Latest Images