[Haskell-cafe] Yet another monad transformer or silly usage of Either?

2010-07-25 Thread Eugeny N Dzhurinsky
Hello, everybody! I am trying to develop some sort of library, which supposed to sign into a WEB service, then perform some requests with it. Initially I designed methods in the following way data DServError = InvalidCredentials | InvalidRequest | ... newtype Result a = Result { getOpResult ::

Re: [Haskell-cafe] MultiParamClasses question

2010-05-26 Thread Eugeny N Dzhurinsky
On Tue, May 25, 2010 at 10:46:47PM +0100, Stephen Tetley wrote: Hi Eugene You can store different things in a Map by collecting them with a simple 'sum' type: Hello, Stephen! The records to be stored into a Map are not related to each other. So wrapping them into another type is not very

[Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Eugeny N Dzhurinsky
Hello, all! I'm trying to create set of polymorphic functions for working with custom containers. I decided to try out typeclass and define generic function, which uses the methods from the typeclass. The quick and naive solution is listed below:

Re: [Haskell-cafe] MultiParamClasses question

2010-05-25 Thread Eugeny N Dzhurinsky
On Tue, May 25, 2010 at 07:59:24PM +0100, Stephen Tetley wrote: Hi Eugeny Its not that GHC thinks you're doing something weird, but that there is no relation between the type parameters in the Storage class. You could use either functional dependencies or type families to introduce a

[Haskell-cafe] Calculating a value as side effect of converting list of strings into list of records.

2010-05-24 Thread Eugeny N Dzhurinsky
Hello, All! I need some help to solve the following task: = import Data.Map as M import Data.List as L data Pair = Pair { name, value :: String } type IxPair = (Int, String, String) type

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 04:43:26PM +0100, Stephen Tetley wrote: Hi Eugene You don't need to supply all the arguments to a constructor at once: makeWithOne :: String - (String - String - Object) makeWithOne s1 = \s2 s3 - Object s1 s2 s3 -- or even: -- makeWithOne s1 = Object s1 This

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 07:15:22PM +0100, Stephen Tetley wrote: On 13 May 2010 19:14, Stephen Tetley stephen.tet...@gmail.com wrote: Hi Eugene Hi Eugeny Whoops - apologies for the the name change... In fact it doesn't make any difference, so both these names are equal :) -- Eugene

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 07:14:25PM +0100, Stephen Tetley wrote: Hi Eugene Is something like this close to what you want: Not really. First of all, there're many properties, not 3. So it may end up with plenty of support (boilerplate) code. Also, names of these parameters are not sortable. Of

Re: [Haskell-cafe] Data creation pattern?

2010-05-13 Thread Eugeny N Dzhurinsky
On Thu, May 13, 2010 at 09:03:48PM +0200, Daniel Fischer wrote: so if it is possible to have partially initialized objects in Haskell, If the fields aren't strict, there's no problem having ... Wow! Thank you, that's it :) -- Eugene Dzhurinsky pgpPXFjii1ixC.pgp Description: PGP signature

[Haskell-cafe] posting UTF8 data with Curl library

2010-05-05 Thread Eugeny N Dzhurinsky
Hello! I need to submit data to HTTP server using UTF8 encoding. I found out that libcurl for haskell can work with Data.ByteString - but it seems not able to work with Data.ByteString.UTF8. Can you please advice, how do I convert Data.ByteString.UTF8 into Data.ByteString and visa versa? Thank

[Haskell-cafe] IO (Either a Error) question

2010-05-01 Thread Eugeny N Dzhurinsky
Hello! I have some sort of strange question: assume that there are 2 functions func1 :: Int - IO (Either Error String) func2 :: String - IO (Either Error [String]) in case if there will be no IO involved, I could use Control.Monad.Either and write something like runCalc :: Int - IO (Either

Re: [Haskell-cafe] CURL and threads

2010-02-17 Thread Eugeny N Dzhurinsky
On Wed, Feb 17, 2010 at 07:34:07PM +0200, Eugene Dzhurinsky wrote: Hopefully, someone could help me in overcoming my ignorance :) I realized that I can share the same Chan instance over all invocations in main, and wrap internal function into withCurlDo to ensure only one IO action gets executed