[Haskell-beginners] data design for a questionnaire (retitled + update)

Antoine Latter aslatter at gmail.com
Thu Nov 24 16:34:12 CET 2011


On Thu, Nov 24, 2011 at 3:32 AM, Alia <alia_khouri at yahoo.com> wrote:
>
> extract :: Question' -> Question a
> extract q = case q of
>     QuestionS x -> extractQString q
>     QuestionI x -> extractQInt q
>     QuestionD x -> extractQDouble q
>

What is a caller supposed to do with this function? How were you
imagining it would be called?

In Haskell98 (or Haskell2010), the type signature `Question' ->
Question a` would mean that the function returns a `Question` of
whatever type the caller chooses. Since this is not what the function
in fact does, the compiler rejects it.

Antoine



More information about the Beginners mailing list