[Haskell-cafe] Cons of -XUndecidableInstances

Scott Lawrence bytbox at gmail.com
Mon Jun 6 09:13:33 CEST 2011


On 06/06/2011 02:57 AM, Yitzchak Gale wrote:
> Generally, we don't start out with a type class. Type classes are
> great for the special situations in which they are needed (although
> you can do pretty well without them even then), but first
> let's get the basic concepts.
> 
> Perhaps a model is just a function:
> 
> type Model a = Ord a => Set a -> [a] -> ProbDist a
> 
> or something like that.

Erm... yeah, actually.

But... this prevents me from storing more information in a Model in the
future. While I don't really anticipate needing too (I can see this
function covering all likely use cases), it does seem sorta restrictive.

> 
>> > Having that working, I'm trying to estimate the information entropy of a model
>> >
>> >  entropy :: (Model m) => m -> Double
> Perhaps just a function:
> 
> entropy :: Model a -> Double
> 
> I still don't know enough details about what you're doing,
> so my types are probably off. But I hope you get the idea.

No, your types are right.

> 
> If that's not general enough, you may introduce more functions, or
> some data types. Those give you a huge amount of power - remember
> that data types can take multiple type parameters (without any
> GHC extension), they can have functions as their parameters, etc.
> 
> Or, perhaps you'll even get to the point where you'll need a type class,
> but that's pretty far down the road, and what you would need it
> for is very different than what a class is in OOP - they are different
> concepts.

Oh, I understand the difference between a class and a typeclass. It's
the difference between an interface and a typeclass that I apparently
haven't grasped. Thanks.

> 
> Hope this helps,
> Yitz


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110606/74c93d39/attachment.pgp>


More information about the Haskell-Cafe mailing list