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: [Haskell-cafe] Multidimensional Matrices in Haskell
(Manuel M T Chakravarty)
2. Re: [Haskell-cafe] Multidimensional Matrices in Haskell
(Manuel M T Chakravarty)
3. Re: [Haskell-cafe] lists of arbitrary depth (Christopher Done)
4. Fwd: My first functioning haskell project - a steganography
utility (Tim Cowlishaw)
5. Re: Fwd: My first functioning haskell project - a
steganography utility (edgar klerks)
6. Re: Fwd: My first functioning haskell project - a
steganography utility (Tim Cowlishaw)
7. Re: Fwd: My first functioning haskell project - a
steganography utility (Brent Yorgey)
8. Re: Fwd: My first functioning haskell project - a
steganography utility (edgar klerks)
----------------------------------------------------------------------
Message: 1
Date: Mon, 12 Jul 2010 12:27:34 +1000
From: Manuel M T Chakravarty <[email protected]>
Subject: [Haskell-beginners] Re: [Haskell-cafe] Multidimensional
Matrices in Haskell
To: Mihai Maruseac <[email protected]>
Cc: [email protected], haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Mihai,
> A friend of mine wanted to do some Cellular Automata experiments in
> Haskell and was asking me what packages/libraries are there for
> multidimensional matrices. I'm interested in both immutable and
> mutable ones but I don't want them to be trapped inside a monad of any
> kind.
You may like to have a look at the recently released Repa library:
http://hackage.haskell.org/package/repa
There is a draft paper about it:
http://www.cse.unsw.edu.au/~chak/papers/KCLPL10.html
Manuel
------------------------------
Message: 2
Date: Mon, 12 Jul 2010 14:54:37 +1000
From: Manuel M T Chakravarty <[email protected]>
Subject: [Haskell-beginners] Re: [Haskell-cafe] Multidimensional
Matrices in Haskell
To: Mihai Maruseac <[email protected]>
Cc: [email protected], haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Mihai,
> A friend of mine wanted to do some Cellular Automata experiments in
> Haskell and was asking me what packages/libraries are there for
> multidimensional matrices. I'm interested in both immutable and
> mutable ones but I don't want them to be trapped inside a monad of any
> kind.
You may like to have a look at the recently released Repa library:
http://hackage.haskell.org/package/repa
There is a draft paper about it:
http://www.cse.unsw.edu.au/~chak/papers/KCLPL10.html
Manuel
------------------------------
Message: 3
Date: Tue, 13 Jul 2010 11:00:53 +0200
From: Christopher Done <[email protected]>
Subject: [Haskell-beginners] Re: [Haskell-cafe] lists of arbitrary
depth
To: vadali <[email protected]>
Cc: [email protected], [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On 13 July 2010 10:58, vadali <[email protected]> wrote:
>
> hello,
> iam really new to haskell,
>
> i want to define a function which takes as a parameter a list which can
> contain other lists, eg. [1,[2,3],[4,[5,6]]]
>
> how would i define a function that can iterate through the items so (in this
> example)
> iter1 = 1
> iter2 = [2,3]
> iter3 = [4,[5,6]]
>
> ?
>
> ( can i do that without using the Tree data type? )
Maybe this should be moved to Haskell-Beginnners.
It's impossible to have a function that works on a list of arbitrary
nesting. But you could use a tree data type, yeah.
------------------------------
Message: 4
Date: Tue, 13 Jul 2010 14:37:17 +0100
From: Tim Cowlishaw <[email protected]>
Subject: [Haskell-beginners] Fwd: My first functioning haskell project
- a steganography utility
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hey there all,
I've just completed my first functional haskell project - a simple utility for
steganography - hiding messages within the least significant bit of another
sort of data file.
Therefore, I was wondering if any of you had any pointers about how I could
refactor or otherwise improve my code? Any input would be greatly appreciated -
whether howling great errors or smaller points of "good haskell style". In
particular, I'd be really interested in whether my type declarations are
correct - for instance, whether I have been to specific or not specific enough
in specifying the types of my functions (Integral vs Int, etc).
In addition, I keep feeling that my Steganograph 'smells like' a monad and/or
functor , as it 'wraps around' a message - however, I'm having trouble defining
quite how I could achieve construct a monadic type representing a steganograph.
Is my hunch incorrect, or is there a way of doing this that I haven't yet
discovered?
The sources is here: http://gist.github.com/473862
Cheers,
Tim
------------------------------
Message: 5
Date: Tue, 13 Jul 2010 16:31:10 +0200
From: edgar klerks <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: My first functioning haskell
project - a steganography utility
To: Tim Cowlishaw <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi Tim,
I have a small remark. You can use maybe from Data.Maybe: b -> (a -> b) ->
Maybe a -> b
to create your maybe plus function:
maybePlus x y = maybe 0 id $ liftM2 (+) x y
That is somewhat cleaner.
Greets,
Edgar
On Tue, Jul 13, 2010 at 3:37 PM, Tim Cowlishaw <[email protected]>wrote:
>
> Hey there all,
>
> I've just completed my first functional haskell project - a simple utility
> for steganography - hiding messages within the least significant bit of
> another sort of data file.
>
> Therefore, I was wondering if any of you had any pointers about how I could
> refactor or otherwise improve my code? Any input would be greatly
> appreciated - whether howling great errors or smaller points of "good
> haskell style". In particular, I'd be really interested in whether my type
> declarations are correct - for instance, whether I have been to specific or
> not specific enough in specifying the types of my functions (Integral vs
> Int, etc).
>
> In addition, I keep feeling that my Steganograph 'smells like' a monad
> and/or functor , as it 'wraps around' a message - however, I'm having
> trouble defining quite how I could achieve construct a monadic type
> representing a steganograph. Is my hunch incorrect, or is there a way of
> doing this that I haven't yet discovered?
>
> The sources is here: http://gist.github.com/473862
>
>
> Cheers,
>
> Tim
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100713/7704ae46/attachment-0001.html
------------------------------
Message: 6
Date: Tue, 13 Jul 2010 15:39:50 +0100
From: Tim Cowlishaw <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: My first functioning haskell
project - a steganography utility
To: edgar klerks <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On 13 Jul 2010, at 15:31, edgar klerks wrote:
> You can use maybe from Data.Maybe: b -> (a -> b) -> Maybe a -> b
>
> to create your maybe plus function:
>
> maybePlus x y = maybe 0 id $ liftM2 (+) x y
>
> That is somewhat cleaner.
Aah thanks Edgar - I'd meant to ask about this specifically actually, as
addition is a monoid over the real numbers and therefore has an identity
element, I was wondering if there was an easier way to generalise it to cope
with arguments in the Maybe monad. As far as I can see, this is precisely what
you describe above. Therefore, would I be right in saying that your approach
can be generalised to any function which forms a monoid over a specific type?
I'm imagining something like:
maybeMonoid :: (a -> a -> a) -> a -> (Maybe a -> Maybe a -> a)
maybeMonoid f identity = maybe identity id $ liftM2 f
Thanks for the feedback!
Cheers,
Tim
------------------------------
Message: 7
Date: Tue, 13 Jul 2010 15:51:08 +0100
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: My first functioning haskell
project - a steganography utility
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Tue, Jul 13, 2010 at 03:39:50PM +0100, Tim Cowlishaw wrote:
> On 13 Jul 2010, at 15:31, edgar klerks wrote:
>
> > You can use maybe from Data.Maybe: b -> (a -> b) -> Maybe a -> b
> >
> > to create your maybe plus function:
> >
> > maybePlus x y = maybe 0 id $ liftM2 (+) x y
Note that 'maybe foo id' is better written 'fromMaybe foo'.
> maybeMonoid :: (a -> a -> a) -> a -> (Maybe a -> Maybe a -> a)
> maybeMonoid f identity = maybe identity id $ liftM2 f
If it really is an instance of the Monoid type class then you could
just write:
maybeMonoid :: (Monoid a) => Maybe a -> Maybe a -> a
maybeMonoid x y = fromMaybe mempty $ liftM2 mappend x y
-Brent
------------------------------
Message: 8
Date: Tue, 13 Jul 2010 16:50:51 +0200
From: edgar klerks <[email protected]>
Subject: Re: [Haskell-beginners] Fwd: My first functioning haskell
project - a steganography utility
To: Tim Cowlishaw <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi Tim,
I am not too deep into category theory. But the Data.Monoid class defines
the identity as mempty. And the binary operation as mappend. So that would
be:
maybePlus = maybe mempty id $ liftM2 (mappend) x y
You only have to define Num as Monoid, because there are more monoids
possible. (Multiplication, addition etc).
That would look something like this:
instance (Num a) => Monoid a where ...
Have a look at the monoid class:
http://haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Data-Monoid.html
Greets,
Edgar
On Tue, Jul 13, 2010 at 4:39 PM, Tim Cowlishaw <[email protected]>wrote:
> On 13 Jul 2010, at 15:31, edgar klerks wrote:
>
> > You can use maybe from Data.Maybe: b -> (a -> b) -> Maybe a -> b
> >
> > to create your maybe plus function:
> >
> > maybePlus x y = maybe 0 id $ liftM2 (+) x y
> >
> > That is somewhat cleaner.
>
> Aah thanks Edgar - I'd meant to ask about this specifically actually, as
> addition is a monoid over the real numbers and therefore has an identity
> element, I was wondering if there was an easier way to generalise it to cope
> with arguments in the Maybe monad. As far as I can see, this is precisely
> what you describe above. Therefore, would I be right in saying that your
> approach can be generalised to any function which forms a monoid over a
> specific type?
>
> I'm imagining something like:
>
> maybeMonoid :: (a -> a -> a) -> a -> (Maybe a -> Maybe a -> a)
> maybeMonoid f identity = maybe identity id $ liftM2 f
>
> Thanks for the feedback!
>
> Cheers,
>
> Tim
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100713/c4e66b21/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 25, Issue 29
*****************************************