Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: How to get HLint working? (Daniel Fischer)
2. Re: data design for a questionnaire (retitled + update)
(David McBride)
3. Re: How to get HLint working? (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Fri, 25 Nov 2011 03:19:36 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] How to get HLint working?
To: [email protected]
Cc: Avery Robinson <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="utf-8"
On Friday 25 November 2011, 02:35:52, 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?
Is
/Users/averyrobinson/Library/Haskell/ghc-7.0.3/lib/hlint-1.8.18/bin
in your path?
Probably not, that directory was likely only created when hlint was first
installed.
That's an odd configuration for cabal to create a new directory for an
executable to install in.
I suggest letting cabal install executables in ~/.cabal/bin (edit your
~/.cabal/config, the install-dirs stanzas; and add that to your path), or,
if you wish some other directory in your path.
------------------------------
Message: 2
Date: Thu, 24 Nov 2011 22:07:51 -0500
From: David McBride <[email protected]>
Subject: Re: [Haskell-beginners] data design for a questionnaire
(retitled + update)
To: Alia <[email protected]>
Cc: "[email protected]" <[email protected]>
Message-ID:
<can+tr43ts+nbdr42sxjgm67uqk8jloslc4ewtdh2kh0gipb...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Why not have:
data Question = Question
{ questionName :: Name
, questionText :: QuestionText
, questionType :: QuestionType
, answerFunc :: (String -> AnswerType)
, correctAnswer :: Maybe AnswerType
, options :: Maybe [Option AnswerType]
} deriving (Show)
data AnswerType = AnsD Double | AnsS String | AnsI Integer deriving (Show, Read)
Then, I'd personally make another change, why would you have a flat
structure with a questionType and then optional correctAnswer and
options fields? There's no type safety in that. I'd try:
data Answer = StraightAnswer (String -> AnswerType) | MultipleChoice
AnswerType [Option AnswerType]
data Question = Question
{ questionName :: Name
, questionText :: QuestionText
, answerFunc :: (String -> AnswerType)
, answer :: Answer
} deriving (Show)
If you are storing answers as string, just store them as "AnsD 5.589",
"AnsS \"Constantiople\"". Then with the read instance you can go:
let answer = read x :: AnswerType
On Thu, Nov 24, 2011 at 4:52 PM, Alia <[email protected]> wrote:
>
> 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)
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
------------------------------
Message: 3
Date: Fri, 25 Nov 2011 00:11:48 -0500
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] How to get HLint working?
To: Daniel Fischer <[email protected]>
Cc: [email protected], Avery Robinson <[email protected]>
Message-ID:
<CAKFCL4Xg_p_z-=rycejwqfkek2ywfkdrs7uca968tgfg8iw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Nov 24, 2011 at 21:19, Daniel Fischer <
[email protected]> wrote:
> Is
>
> /Users/averyrobinson/Library/Haskell/ghc-7.0.3/lib/hlint-1.8.18/bin
>
> in your path?
> Probably not, that directory was likely only created when hlint was first
> installed.
> That's an odd configuration for cabal to create a new directory for an
> executable to install in.
>
Yes, but Haskell Platform cabal on OS X does that sometimes (I haven't
figured out the logic behind when it does so and when it uses
~/Library/Haskell/bin --- note, *not* ~/.cabal/bin, H-P changed the paths
for OS X), but I also haven't tried very hard to figure it out.
--
brandon s allbery [email protected]
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20111125/b8337ecc/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 41, Issue 36
*****************************************