[Haskell-beginners] type class question

Ben midfield at gmail.com
Fri Sep 18 12:04:22 EDT 2009


On Fri, Sep 18, 2009 at 8:28 AM, Daniel Fischer
<daniel.is.fischer at web.de> wrote:
> No, summarizeMany would have the type
>
> (Summarizer m s) => [Double] -> Double
>
> which is ambiguous. You would have to make m somehow accessible (dummy argument?).

yes, i realize the type is ambiguous, ghc even says so in the error
message.  but a dummy argument doesn't seem very elegant.

>> 2) is there a better way of expressing this kind of "on-line"
>> calculation, perhaps in pure (non-monadic) functions?
>
> Perhaps scanl ?

i originally was using mapAccumL (i need the final result of the
state) but it seemed like i was missing the point of the State monad.
i guess that is a matter of opinion?

b


More information about the Beginners mailing list