[Haskell-beginners] How do I give a type for this code?

Todd Wilson twilson at csufresno.edu
Fri Oct 18 04:58:08 UTC 2013


Thanks, Daniel, for your suggestion, but I think it misses a key aspect of
my situation (unless I've misunderstood).  Every model is supposed to be a
quadruple (m, q, f, p), with m a list, q an element of m, f a list of
ordered pairs of elements of m, and p a sublist of m.  By contrast, it
looks like your definition makes a model either a single element, or a
single pair, or a single list, etc.

--Todd


On Thu, Oct 17, 2013 at 4:12 AM, Daniel Trstenjak <
daniel.trstenjak at gmail.com> wrote:

>
> Hi Todd,
>
> the problem is, that 'model_of' tries to return different types: Model a,
> Model (a,a) and Model [a].
>
> I think you have to use some kind of ADT also for the Model, like you
> already did for ModName.
>
> Something like:
>
>    data Model a = Model a
>                 | ProductModel (a,a)
>                 | PowerModel [a]
>                 ...
>
>
> Greetings,
> Daniel
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131017/51e40dc7/attachment.html>


More information about the Beginners mailing list