On Feb 5, 2008 2:28 AM, Bulat Ziganshin <[EMAIL PROTECTED]> wrote:
> this principle allows to build programs in quick and easy way: we just
> add to objects implementations of all the methods required:
>
> e = new Entry {label := "Hi",
> color := blue,
> getValue := getEntryValue,
> setValue := setEntryValue}
>
> e.display -- uses color/label properties
> e.saveToFile -- uses getValue property
I'm new to all this -- I can't figure out why we want to put
methods inside of records. Why don't we define a module instead?
module EntryModule where
data Entry = Entry String Color
display (Entry s c) = do someIOMagic
saveToFile (Entry s c) = do someOtherIOMagic
If we want a more generic approach -- where a function excepts
one of many kinds of data -- than is a type class not suitable?
--
_jsn
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell