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. Invitation to connect on LinkedIn (Andrew Smith B.Sc(Hons),MBA)
2. Re: a simple little problem (Brent Yorgey)
3. Re: a simple little problem (Brandon Allbery)
4. How to find a "best alternative" (Martin Drautzburg)
5. abstype? (Christopher Howard)
6. Re: abstype? (Alexander Dunlap)
7. Iterating a monadic action with memoization (Tim Cowlishaw)
8. Re: Iterating a monadic action with memoization (Tim Cowlishaw)
----------------------------------------------------------------------
Message: 1
Date: Sun, 14 Aug 2011 16:32:13 +0000 (UTC)
From: "Andrew Smith B.Sc(Hons),MBA" <[email protected]>
Subject: [Haskell-beginners] Invitation to connect on LinkedIn
To: <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
LinkedIn
------------
I'd like to add you to my professional network on LinkedIn.
- Andrew
Andrew Smith B.Sc(Hons),MBA
Founder and CEO at VTRL - Value Technology Research Ltd
Edinburgh, United Kingdom
Confirm that you know Andrew Smith B.Sc(Hons),MBA
https://www.linkedin.com/e/-3dpk6t-grc8g5b9-3s/isd/3853823396/wkuHdNPh/
--
(c) 2011, LinkedIn Corporation
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110814/f0dee379/attachment-0001.htm>
------------------------------
Message: 2
Date: Sun, 14 Aug 2011 12:36:43 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] a simple little problem
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sat, Aug 13, 2011 at 02:47:04PM -0400, Brandon Allbery wrote:
> On Sat, Aug 13, 2011 at 14:04, Dennis Raddle <[email protected]>wrote:
>
> > Can someone suggest an elegant way to write the following?
> >
> > fn :: [Maybe Float] -> Maybe Float
> >
> > in which, if the input list has all Nothing, then the result is Nothing
> > if the input list has one or more Just x, then the result is Just x
> > (in which the x is picked arbitrarily, could be the first one or last
> > one)
> >
>
> Isn't this just mconcat?
No. The Monoid instance for Maybe defined in Data.Monoid is the one
which lifts a Monoid instance on a to a Monoid instance on Maybe a.
That is, all the Nothings are discarded and all the Justs combined
according to the Monoid instance on a. For example:
> mconcat [Nothing, Just "hello", Nothing, Just "world"]
Just "helloworld"
The MonadPlus instance for Maybe is what the OP wants (as I think
someone else already pointed out), which is sensible, since the Maybe
monad models possible failure, and hence the MonadPlus instance models
choosing the first success.
-Brent
------------------------------
Message: 3
Date: Sun, 14 Aug 2011 13:24:31 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] a simple little problem
To: Brent Yorgey <[email protected]>
Cc: [email protected]
Message-ID:
<CAKFCL4U-0yFA=dca_vobist0pcbuls9kk34wlh1mgjyysto...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sun, Aug 14, 2011 at 12:36, Brent Yorgey <[email protected]> wrote:
> On Sat, Aug 13, 2011 at 02:47:04PM -0400, Brandon Allbery wrote:
> > Isn't this just mconcat?
>
> No. The Monoid instance for Maybe defined in Data.Monoid is the one
> which lifts a Monoid instance on a to a Monoid instance on Maybe a.
>
Yeh, as usual I realized that about 5 minutes after sending, by which time
someone else had already pointed 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/20110814/7598ada2/attachment-0001.htm>
------------------------------
Message: 4
Date: Sun, 14 Aug 2011 21:11:21 +0200
From: Martin Drautzburg <[email protected]>
Subject: [Haskell-beginners] How to find a "best alternative"
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="us-ascii"
Hello all,
I want to write transformations on musical motives and I came upon the
following algorithmic question:
For every note of the original motiv I can compute a sequence of transformend
notes which are ordered by their "fitness" with respect of a certain
criterion. If might for example compute the "fitness with respect to harmonic
function". I have a whole set of such criteria. So in the end the questions
are:
what should the first transformend note be? Harmonic function tells me it
should be a G, but could also be a C or a D ..., some other function tells me
it should be a C, but could also be a C# or a Cb.
It kind of reminds me of the Levenshtein Disance, but this gives me a
"distance" from two samples. I need a function which returns a new sample when
one sample is given, i.e. the one with the smallest distance.
Any idea in which direction is shall focus my thoughts?
--
Martin
------------------------------
Message: 5
Date: Sun, 14 Aug 2011 21:06:28 -0800
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] abstype?
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
In my older (1992) intro programming book, the author uses the keyword
"abstype" instead of "data" inside of module code. From what I can
gather, abstype is supposed to hide constructors. But I've never seen
this keyword used in any modern tutorials I've gone through. Is
"abstype" still a valid keyword? Is is still relevant?
--
frigidcode.com
theologia.indicium.us
------------------------------
Message: 6
Date: Sun, 14 Aug 2011 22:52:11 -0700
From: Alexander Dunlap <[email protected]>
Subject: Re: [Haskell-beginners] abstype?
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
<cakdsjnfn0nr287rd7vceara0cfihjsmopowhhxlx_8rk-sy...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
abstype is not currently a keyword in Haskell. To hide constructors
from client modules, use an explicit module export list, and don't
include the constructors in the list.
For example,
module MyModule ( Foo ) where
data Foo = Bar Int | Baz Float | Bat Double
will make Foo an abstract type, since Bar, Baz, and Bat are not exported.
Similarly,
module MyModule ( Foo ) where
data Foo = Foo Int
will also make Foo an abstract type, since Foo in the export list
refers to the type Foo, not the constructor Foo (which happens to have
the same name). To export Foo and its constructors, use Foo (..) in
the export list, or list the constructors explicitly: Foo ( Bar, Baz,
Bat ) for the first example, or Foo ( Foo ) for the second example.
Hope that helps.
Alexander
On 14 August 2011 22:06, Christopher Howard
<[email protected]> wrote:
> In my older (1992) intro programming book, the author uses the keyword
> "abstype" instead of "data" inside of module code. From what I can gather,
> abstype is supposed to hide constructors. But I've never seen this keyword
> used in any modern tutorials I've gone through. Is "abstype" still a valid
> keyword? Is is still relevant?
>
> --
> frigidcode.com
> theologia.indicium.us
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 7
Date: Mon, 15 Aug 2011 09:00:19 +0100
From: Tim Cowlishaw <[email protected]>
Subject: [Haskell-beginners] Iterating a monadic action with
memoization
To: [email protected]
Message-ID:
<CAMugUeK56PMT5MD9wrfR=+BKSizw=xC=5Bx=a-7nspnkwrd...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
I was wondering if any of you knew whether the following was possible,
(I discussed this a little on #haskell at the weekend but didn't quite
get to the bottom of it):
Say I have a monadic action:
> f :: a -> m a
and an initial value of type a.
I'd like to iterate this action and collect the results of each
iteration in a list, as with 'iterate' on normal functions:
> iterate (>>= f) . return $ a
However, I would also like to memoize the intermediate results of the
iteration, such that the entire iteration runs in O(n) time rather
than O(n^2). This also implies a slight semantic difference, as
side-effecting or non-deterministic actions will not be repeated in
each iteration, while maintaining the laziness of the iteration
function. Is it possible to do this?
Many thanks,
Tim
------------------------------
Message: 8
Date: Mon, 15 Aug 2011 09:06:59 +0100
From: Tim Cowlishaw <[email protected]>
Subject: Re: [Haskell-beginners] Iterating a monadic action with
memoization
To: [email protected]
Message-ID:
<camuguejd+esjagazkopdid0fhbm6kpyjqw-4awpgffptvss...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Aug 15, 2011 at 9:00 AM, Tim Cowlishaw <[email protected]> wrote:
>> iterate (>>= f) . return $ a
Sorry, I meant:
> sequence . iterate (>>= f) . return $ a
Thanks,
Tim
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 38, Issue 30
*****************************************