[Haskell-beginners] How to add a "method" to a record

martin martin.drautzburg at web.de
Wed Sep 10 18:06:26 UTC 2014


Hello all

if I have a record like

	data Foo pl = Foo {
	            label :: String,
	            payload :: pl
	        }

how can I create a similar type where I can populate label so it is not a plain string, but a function which operates on
payload? Something like

	label (Foo pl) = show pl




More information about the Beginners mailing list