[Haskell-cafe] how can I do this the best

Konstantine Rybnikov k-bx at k-bx.com
Sun Feb 22 22:35:13 UTC 2015


So, as the simplest solution -- you need to read file, split it by lines
(convert it to list of lines), for each line check it for validity and
return some result, which would have type, for example

Either String LogMsg

, where Left String indicates error, and other one is Right LogMsg, with
this type:

data LogLevel = LevelW | LevelE | LevelI
data LogMsg = LogMsg LogLevel Int String

Then you would filter all rights to output to new logfile, and filter all
lefts to do whatever you wanted to do with them (you didn't specify this, I
think).

Does this look clear?

Ask if you have more questions!
 22 лют. 2015 18:24, користувач "Roelof Wobben" <r.wobben at home.nl> написав:

>  Sorry,
>
> I stand for Info
> E stands for Error
> W stands for Warning.
>
> The clause Im talking about is that the log message must be the format
> char Int [char]  so like this:  W 10 this is a warning
> All the sentences that are not of this format , like for example this one:
>   W this is a false warning , must have another output.
> That's is also true when the first Char is not a W, E or I.
>
> When it's a W , E, or I then the char must be converted to the word
> Warning, Error or Info.
>
> I hope it's clear now what I want.
>
> Roelof
>
>
>
> Konstantine Rybnikov schreef op 22-2-2015 om 16:17:
>
> Hi Roelof,
>
> You forgot to explain what are those fields you are talking about, and
> what are  I/E/W . Also what are those clauses you are talking about?
>
> Cheers.
> 21 лют. 2015 09:03, користувач "Roelof Wobben" <r.wobben at home.nl> написав:
>
>> Hello,
>>
>>
>> Im busy with a programm which translates log files to another format.
>> I also have to look if the lines in the old one have the rigtht format.
>>
>> Schould I check  the format and also if another  field contains a I, E or
>> W.
>> Or schould I do the checking in one clause and make another case  on the
>> rest ?
>>
>> Roelof
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150223/a42ebfeb/attachment.html>


More information about the Haskell-Cafe mailing list