Patrick Browne wrote:
Hi,
I am trying to understand the data type declaration below.
What is the relation between class C3 and the data type Address below?
Where is such a technique used?
OK, let's see what we can come up with...
module A where
data Person = Person String Integer deriving
Ivan Miljenovic wrote:
On 25 July 2010 05:50, Tobias Brandt tob.bra...@googlemail.com wrote:
You have to fix the type of 1 and 6, e.g. by writing
x - randomRIO (1, 6) :: IO Int
or
x - randomRIO (1, 6 :: Int)
GHCi defaults integral numbers to Int, that's why it works there.
The
On Sunday 25 July 2010 14:12:03, Andrew Coppin wrote:
Ivan Miljenovic wrote:
On 25 July 2010 05:50, Tobias Brandt tob.bra...@googlemail.com wrote:
You have to fix the type of 1 and 6, e.g. by writing
x - randomRIO (1, 6) :: IO Int
or
x - randomRIO (1, 6 :: Int)
GHCi defaults integral
Daniel Fischer wrote:
On Sunday 25 July 2010 14:12:03, Andrew Coppin wrote:
Isn't there a default declaration where you can specify type
defaulting?
Yes, you can have one default declaration per module.
Not a feature I ever use. I just vaguely remembered reading about it
On Sunday 25 July 2010 14:47:41, Andrew Coppin wrote:
Daniel Fischer wrote:
On Sunday 25 July 2010 14:12:03, Andrew Coppin wrote:
Isn't there a default declaration where you can specify type
defaulting?
Yes, you can have one default declaration per module.
Not a feature I ever use. I
On 25 July 2010 13:09, Andrew Coppin andrewcop...@btinternet.com wrote:
This is not valid in Haskell '98. This is actually a type system extension
known as multi-parameter type classes, which do not even vaguely
correspond to anything in normal OOP. (Except for being very slightly
similar to
-- Is it true that instances must exists before we can run function
or
make subclasses?
instance C1 Person where
instance C1 Employee where
You can *call* class methods only for types which are instances of
that
class.
But you can certain *write* functions that make use of the class
Andrew,
Thanks for your detailed feedback, it is a great help.
I appreciate that the code does not do anything useful, nor is it an
appropriate way to write Haskell, but it does help me
understand language constructs. I have seen statements like
data C3 c3 a = Address c3 a = Address c3 a
and
Hi,
I'm a beginner in haskell, I was trying to write the following code, but I
still encourage some problems, can you help me with that?
I need to read a large file and try to match each line to a pattern which is
int,int value=string
for example:
0,1 value=string1
1,5 value=string2
when the
Patrick Browne wrote:
Andrew,
Thanks for your detailed feedback, it is a great help.
Well, I like to be helpful.
I appreciate that the code does not do anything useful, nor is it an
appropriate way to write Haskell, but it does help me
understand language constructs.
Personally, I find
2010/7/25 Andrew Coppin andrewcop...@btinternet.com:
Patrick Browne wrote:
Andrew,
Thanks for your detailed feedback, it is a great help.
Well, I like to be helpful.
I appreciate that the code does not do anything useful, nor is it an
appropriate way to write Haskell, but it does help me
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 ::
Hi All,
From: http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State
Exercises
1. Implement a function rollNDiceIO :: Int - IO [Int] that,
given an integer, returns a list with that number of pseudo-
random integers between 1 and 6.
After a
On Sun, Jul 25, 2010 at 5:39 PM, michael rice nowg...@yahoo.com wrote:
I know, ugly, but at least I got it to work. What's a better way to generate
this list?
rollNDiceIO n
= sequence . replicate n $ randomRIO (1,6)
{{ sequence . replicate n = replicateM n }}
= replicateM n $ randomRIO
Look for the function replicateM in the module Control.Monad.
On 25 July 2010 17:39, michael rice nowg...@yahoo.com wrote:
Hi All,
From: http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State
Exercises
1. Implement a function rollNDiceIO :: Int - IO
Hi Max,
Wow!
I tried both *sequence* and *replicate* but guess I didn't put them together
properly. I didn't even know there was a *replicateM*.
Much cleaner.
Thanks
Michael
--- On Sun, 7/25/10, Max Rabkin max.rab...@gmail.com wrote:
From: Max Rabkin max.rab...@gmail.com
Subject: Re:
Vo Minh Thu wrote:
2010/7/25 Andrew Coppin andrewcop...@btinternet.com:
Since you're interested in comparisons... A method is simply a way of giving
the same name to several different functions, and have the compiler pick the
correct one based on the argument types.
[snip]
Actually in
Yeah, ErrorT should do what you want (EitherT is probably essentially the
same thing)
login would have the type:
login :: String - String - ErrorT DServError IO LoginResponse
and you would use it like this:
result - runErrorT $ authenticatedReq
You can use runErrorT, or catch when you want to
2010/7/25 Eugeny N Dzhurinsky b...@redwerk.com:
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 |
Sorry but I'll just go ahead and eta reduce it :)
rollNDiceIO = flip replicateM $ randomRIO (1,6)
On 25 July 2010 16:44, Max Rabkin max.rab...@gmail.com wrote:
On Sun, Jul 25, 2010 at 5:39 PM, michael rice nowg...@yahoo.com wrote:
I know, ugly, but at least I got it to work. What's a
Cool. Everything's there but the N.
Learning Haskell is a lot like learning to dance.
Michael
--- On Sun, 7/25/10, Ozgur Akgun ozgurak...@gmail.com wrote:
From: Ozgur Akgun ozgurak...@gmail.com
Subject: Re: [Haskell-cafe] Random this! ;-)
To: Max Rabkin max.rab...@gmail.com
Cc: michael rice
Suppose I have one piece of code like this:
class Result r e | r - e where
failure :: e - r a
success :: a - r a
at :: Result r String = [a] - Int - r a
at xs i = if i = 0 i length xs
then success (xs !! i)
else failure Wrong index
Either instance of
Hello !
I've been studying Erlang and Scala, and I was wondering if someone has
already implemented an actors and message passing framework for concurrent
and distributed programs in Haskell.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Eta-reducing is nice, and sometimes it makes code more readable. But 'flip'
is one of those functions that always seems to hinder rather than help
readability, conversely factoring out flip always makes code easier to
comprehend. I don't see a need for its existence - maybe I'm missing
something
On Sun, Jul 25, 2010 at 4:13 PM, aditya siram aditya.si...@gmail.com wrote:
Eta-reducing is nice, and sometimes it makes code more readable. But 'flip'
is one of those functions that always seems to hinder rather than help
readability, conversely factoring out flip always makes code easier to
On Sunday 25 July 2010 23:13:16, aditya siram wrote:
Eta-reducing is nice, and sometimes it makes code more readable. But
'flip' is one of those functions that always seems to hinder rather than
help readability, conversely factoring out flip always makes code easier
to comprehend. I don't see
But what to do with Maybe?
instance Result Maybe where
type Failure Maybe = forall e. e -- can't do this
failure _ = Nothing
success x = Just x
Normally, I would use: type Failure Maybe = ()
Unless the ability to discard information of any type is somehow a salient
feature.
Excerpts from aditya siram's message of Sun Jul 25 17:13:16 -0400 2010:
Eta-reducing is nice, and sometimes it makes code more readable. But 'flip'
is one of those functions that always seems to hinder rather than help
readability, conversely factoring out flip always makes code easier to
Volker Stolz and Frank Huch implemented Erlang style
distribution/concurrency for Haskell quite a while ago - a search
should turn up the relevant papers, the code might have disappeared.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hey all,
This is on OpenSolaris. Simple attempts to build cabal packages
give me this error, and I don't know what it means. Here's an
example:
[07/25 18:51::la...@sol type-level]$ runghc Setup.hs configure
Configuring type-level-0.2.4...
Setup.hs: fd:8: hGetContents: resource exhausted
On 26 July 2010 06:55, Yves Parès limestr...@gmail.com wrote:
I've been studying Erlang and Scala, and I was wondering if someone has
already implemented an actors and message passing framework for concurrent
and distributed programs in Haskell.
I've recently been working on MPI bindings for
From: Patrick Browne patrick.bro...@dit.ie
Andrew,
Thanks for your detailed feedback, it is a great help.
I appreciate that the code does not do anything useful, nor is it an
appropriate way to write Haskell, but it does help me
understand language constructs. I have seen statements like
Hello,
I find that parser correctness is often hard to verify. Therefore, I'm
interested in techniques that others have used successfully, especially with
Haskell.
Techniques I'm aware of:
* Round trip checks: Generate a datastructure, render as a string, parse
back, and compare. Quickcheck
On 26 July 2010 00:48, grzyb zbigniew.grzy...@gmail.com wrote:
Hi,
I'm a beginner in haskell, I was trying to write the following code, but I
still encourage some problems, can you help me with that?
I need to read a large file and try to match each line to a pattern which is
int,int
On Jul 26, 2010, at 12:35 PM, John Lato wrote:
Incidentally, there seems to be a consensus that this a Bad Idea [1].
Even when you specify a type class context on a data declaration,
Haskell still requires you to specify the context on functions that
use that data (Address c a).
This has
I have a series of files with binary encoded data in them, and want to create
an enumerator iterates on the first element at the front of all the files.
Something like the pseudocode: return . minimum = mapM (fmap (heads . lines)
readFile) listOfFileNames
I can use convStream to create an
36 matches
Mail list logo