Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  data design for a questionnaire (retitled +  update) (Alia)
   2. Re:  data design for a questionnaire (retitled +  update) (Alia)
   3.  lhs to html (Tim Pizey)
   4.  Cabal on mac (Tim Pizey)
   5. Re:  Cabal on mac (Daniel Fischer)
   6.  How to get HLint working? (Avery Robinson)
   7. Re:  How to get HLint working? (Erik de Castro Lopo)


----------------------------------------------------------------------

Message: 1
Date: Thu, 24 Nov 2011 13:44:27 -0800 (PST)
From: Alia <alia_kho...@yahoo.com>
Subject: Re: [Haskell-beginners] data design for a questionnaire
        (retitled +     update)
To: Antoine Latter <aslat...@gmail.com>
Cc: "beginners@haskell.org" <beginners@haskell.org>
Message-ID:
        <1322171067.38551.yahoomail...@web65709.mail.ac4.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"


> extract :: Question' -> Question a
> extract q = case q of
>???? QuestionS x -> extractQString q
>???? QuestionI x -> extractQInt q
>???? QuestionD x -> extractQDouble q

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

The sole purpose of the above function would be to unbox the inner parametrized 
(Question a) type
from its (Question') wrapper. If it were possible I could write this:

testQ' :: Question' -> Answer -> Bool
testQ' q a = testQ (extract q) a

given:

testQ :: (Eq a) => Question a -> Answer -> Bool
testQ q ans = case (correctAnswer q) of
??? Nothing -> False
??? Just x? -> x == (answerFunc q $ ans)

instead of this

testQ' :: Question' -> Answer -> Bool
testQ' q a = case q of
??? QuestionS x -> testQS q a
??? QuestionI x -> testQI q a
??? QuestionD x -> testQD q a
??? where
??????? testQS q a = testQ (extractQString q) a
??????? testQI q a = testQ (extractQInt??? q) a
??????? testQD q a = testQ (extractQDouble q) a

In fact this seemingly redundant pattern emerges in all wrapper handling code, 
for instance:

askQ' :: Question' -> IO Answer
askQ' q = case q of
??? QuestionS x -> askQS q
??? QuestionI x -> askQI q
??? QuestionD x -> askQD q
??? where
??????? askQS q = askQ (extractQString q)
??????? askQI q = askQ (extractQInt??? q)
??????? askQD q = askQ (extractQDouble q)

Hope this clarifies things somewhat.

Alia

Alia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111124/05df6f05/attachment-0001.htm>

------------------------------

Message: 2
Date: Thu, 24 Nov 2011 13:52:54 -0800 (PST)
From: Alia <alia_kho...@yahoo.com>
Subject: Re: [Haskell-beginners] data design for a questionnaire
        (retitled +     update)
To: Peter Hall <peterj...@gmail.com>
Cc: "beginners@haskell.org" <beginners@haskell.org>
Message-ID: <1322171574.611.yahoomail...@web65704.mail.ac4.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"


Peter Hall wrote:

> Might this be easier if you made all the answers strings? If you need to 
> permit things like 0.5 vs .5 you could instead > use a String->String 
> normalisation function which could vary with the "type" of the answer but not 
> affect the data type > of the question.
> It would also be easier to use strings if you wanted to store the questions 
> in a database or load from a file. ?

Indeed that is exactly how I do it. All user entered answers are stored as 
strings, and are converted to the
appropriate type by an answerFunc (see below) and compared against correct 
answers. The purpose of the
answerFunc is simply to convert (String -> type of answer) and can include 
normalization if required. 
Fyi, the complete schema is as follows:

data QuestionType?? = Open
??????????????????? | Test 
??????????????????? | Choice 
????????????????????? deriving (Show, Eq)

data Question a = Question
??? { questionName??? :: Name
??? , questionText??? :: QuestionText
??? , questionType??? :: QuestionType
??? , answerFunc????? :: (String -> a)
??? , correctAnswer?? :: Maybe a
??? , options???????? :: Maybe [Option a]
??? } deriving (Show)

data Question' = QuestionS (Question String) 
?????????????? | QuestionI (Question Int) 
?????????????? | QuestionD (Question Double)? 
???????????????? deriving (Show)

data QuestionSet = QuestionSet
??? { qsetTitle???? :: String
??? , qsetQuestions :: [Question']
??? , qsetPoints??? :: Double
??? } deriving (Show)

data Survey = Survey
??? { surveyTitle??????? :: String
??? , surveyQuestionSets :: [QuestionSet]
??? } deriving (Show)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111124/1baed91a/attachment-0001.htm>

------------------------------

Message: 3
Date: Thu, 24 Nov 2011 22:36:03 +0000
From: Tim Pizey <t...@paneris.org>
Subject: [Haskell-beginners] lhs to html
To: beginners <beginners@haskell.org>
Message-ID:
        <CAArDntiA3quNQ=ynrluj3z6c5aoo-nqxvclxw+wyxbniapz...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

I am a happy user of lhs2tex but I cannot get the resultant .tex file to html,
with line breaks intact.

Both tex4ht and htlatex lose line breaks.

htlatex also gives
! Missing { inserted.
<to be read again>
                   }
l.814 \end{pboxed}

pdflatex gives the correctly formatted pdf.

Any suggestions?

My do.sh:
lhs2TeX -o xhtml.tex xhtml.lhs
latex xhtml.tex
latex xhtml.tex
tex4ht  xhtml.tex
#htlatex  xhtml.tex
pdflatex xhtml.tex
ghc -fhpc -o xhtml main.lhs xhtml.lhs
xhtml

cheers
Tim
-- 
Tim Pizey
http://pizey.net/~timp



------------------------------

Message: 4
Date: Fri, 25 Nov 2011 00:32:13 +0000
From: Tim Pizey <t...@paneris.org>
Subject: [Haskell-beginners] Cabal on mac
To: beginners <beginners@haskell.org>
Message-ID:
        <CAArDnti=o-mxhtihnjdx3tbn4wovx0bdmoqmqiaig3hmn8w...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Hi,

I have installed cabal and HaxMl

cabal install HaXml

but my .hs file cannot find

import Text.XML.HaXml.Xml2Haskell (readXml)

giving

*** Chasing dependencies:
Chasing modules from: *ch.hs

ch.hs:3:8:
    Could not find module `Text.XML.HaXml.Xml2Haskell':
      locations searched:
        Text/XML/HaXml/Xml2Haskell.hs
        Text/XML/HaXml/Xml2Haskell.lhs

It would seem only to be looking in the current directory.

Hoping I have just missed something obvious.
Tim

-- 
Tim Pizey
http://pizey.net/~timp



------------------------------

Message: 5
Date: Fri, 25 Nov 2011 01:48:58 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] Cabal on mac
To: beginners@haskell.org
Message-ID: <201111250148.58289.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Friday 25 November 2011, 01:32:13, Tim Pizey wrote:
> Hi,
> 
> I have installed cabal and HaxMl
> 
> cabal install HaXml
> 
> but my .hs file cannot find
> 
> import Text.XML.HaXml.Xml2Haskell (readXml)
> 
> giving
> 
> *** Chasing dependencies:
> Chasing modules from: *ch.hs
> 
> ch.hs:3:8:
>     Could not find module `Text.XML.HaXml.Xml2Haskell':
>       locations searched:
>         Text/XML/HaXml/Xml2Haskell.hs
>         Text/XML/HaXml/Xml2Haskell.lhs
> 
> It would seem only to be looking in the current directory.
> 
> Hoping I have just missed something obvious.

In a way.

Text.XML.HaXml.Xml2Haskell was in HaXml-1.13, but is no longer in HaXml 
since version 1.19 (current is 1.22.5). Old tutorial, I guess.

There are two functions with the name readXml in the new versions, in
Text.XML.HaXml.XmlContent and Text.XML.HaXml.XmlContent.Haskell
(probably the same function, just exported from both modules).

The type has changed, instead of XmlContent a => String -> Maybe a, it is 
now XmlContent a => String -> Either String a, presumably specifying the 
parse failure now if there is one, otherwise I expect the behaviour to be 
the same.



------------------------------

Message: 6
Date: Thu, 24 Nov 2011 20:35:52 -0500
From: Avery Robinson <av...@averyrobinson.name>
Subject: [Haskell-beginners] How to get HLint working?
To: beginners@haskell.org
Message-ID:
        <ca+6vedlkxb-tydvtm+x1bamjjkgo2j_c8ozjcfvhml8z24k...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello,

I'm trying to install HLint but I can't figure out how to use it. It seems
like the install works, but when I type "hlint file.hs" my terminal gives
an error. Here's a copy of my terminal output: http://pastebin.com/n071J2mL

It looks like the install works, but at the end you can see that it doesn't
function as I am expecting. I'm having difficulty finding relevant
documentation. Help please?

Avery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20111124/be638327/attachment-0001.htm>

------------------------------

Message: 7
Date: Fri, 25 Nov 2011 13:04:24 +1100
From: Erik de Castro Lopo <mle...@mega-nerd.com>
Subject: Re: [Haskell-beginners] How to get HLint working?
To: beginners@haskell.org
Message-ID: <20111125130424.aa559af9a1d875251bb09...@mega-nerd.com>
Content-Type: text/plain; charset=US-ASCII

Avery Robinson wrote:

> Hello,
> 
> I'm trying to install HLint but I can't figure out how to use it. It seems
> like the install works, but when I type "hlint file.hs" my terminal gives
> an error. Here's a copy of my terminal output: http://pastebin.com/n071J2mL
> 
> It looks like the install works, but at the end you can see that it doesn't
> function as I am expecting. I'm having difficulty finding relevant
> documentation. Help please?

If you do:

   /Users/averyrobinson/Library/Haskell/ghc-7.0.3/lib/hlint-1.8.18/bin/hlint 
file.hs

is should work.

Is should also work if you do:

   ~/.cabal/bin/hlint file.hs

If the second one works, then you should add $HOME/.cabal/bin to your
PATH environment variable.

HTH,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 41, Issue 35
*****************************************

Reply via email to