On 06/06/2011 03:13 AM, Scott Lawrence wrote:
>> 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.
> 

Or not.

  type Model a = (Ord a) => Set a -- the set of lexemes
                         -> [a] -- the original text to model
                         -> [a] -- list of previous lexemes
                         -> ProbDist a -- the next lexeme

and then

  entropy :: Model a -> Set a -> [a] -> Double

or perhaps more simply

  entropy :: [a] -> ProbDist a -> Double

(Let me know if I'm doing something insane again - thanks.)

But this doesn't allow me to specialize for markov models. Seems to me
that to do that, I'd have to store data - and once I'm using a datatype
for markov models:

  data Markov a = Markov
    { lexemeSet :: Set a
    , matrix    :: Map [a] (ProbDist a)
    }

Then in order to get a consistent interface to various models, I'm going
to need a typeclass. (Which is required to use a single function name on
multiple datatypes, yes?)

I suppose the alternative is something like

  data Model a = Markov {...} | OtherModel

Is that the functional solution? It seems to preclude the possibility of
separating the markov-specialized code and the other specialized code.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to