[Haskell-cafe] Cons of -XUndecidableInstances

Scott Lawrence bytbox at gmail.com
Tue Jun 7 18:27:55 CEST 2011


I wrote:
>  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

On Mon, Jun 6, 2011 at 03:56, Yitzchak Gale <gale at sefer.org> wrote:
> If further down the line you need to write a function that is independent
> of the model, the types of its arguments will show you what you
> need to do.

Is there a trick that I'm missing? If I want (as a horribly
constructed hypothetical example) to write a function later on with
type (Model a -> Model b) that calls 'entropy' (no idea why), but I
want to use the specialized version of 'entropy' for 'Markov' (which
requires data that isn't even contained in the first argument, which
is really just a function), I don't see any way to do it, without
having two entirely different code paths for 'Markov' and other
models, starting from the point of decision (user input or some other
factor) - an unwieldy solution in case of more than 2 different models
(each, presumably, with their own subset of specializations).



-- 
Scott Lawrence



More information about the Haskell-Cafe mailing list