Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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: Beginners Digest, Vol 100, Issue 7 (Lai Boon Hui)
2. Regarding defining cases exhaustively (Lai Boon Hui)
3. Re: Regarding defining cases exhaustively (Frerich Raabe)
----------------------------------------------------------------------
Message: 1
Date: Sun, 9 Oct 2016 20:32:54 +0800
From: Lai Boon Hui <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 7
Message-ID:
<CAJdQggknW8iHyX7hPY8P0zvk=e6sf9u75dnqvyabqhjjxvr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Tom,
this indeed led to more questions. I believe that was happening because x
is not a list of concrete types. In determining the concrete type of the
list GHCI evaluated all values hence
λ> let foo = [1,2,3] :: [Int]
Prelude|
foo :: [Int]
λ> :sprint foo
foo = [1,2,3]
I tried on other concrete types like [Char] and String...seems like [Char]
is not entire the same as String after all
λ> let x = ['a','b','c']
Prelude|
x :: [Char]
λ> let y = "abc"
Prelude|
y :: [Char]
λ> :sprint x
x = "abc"
λ> :sprint y
y = _
On Sun, Oct 9, 2016 at 8:00 PM, <[email protected]> wrote:
> Send Beginners mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.haskell.org/cgi-bin/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: Basic sound playing on Windows? (Tilmann)
> 2. Re: Basic sound playing on Windows? (Cleverson Casarin Uliana)
> 3. Lazy evaluation, trying to find out when its done (Lai Boon Hui)
> 4. Re: Lazy evaluation, trying to find out when its done
> (Tom Murphy)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 8 Oct 2016 15:19:35 +0200
> From: Tilmann <[email protected]>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <[email protected]>
> Subject: Re: [Haskell-beginners] Basic sound playing on Windows?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> I used ALUT on OSX and it worked perfectly. Not used it on windows yet,
> but according to the documentation it's supported.
>
>
> Have a look here for how to use it on windows:
>
> https://hackage.haskell.org/package/OpenAL
>
>
> and here for some examples:
>
> https://github.com/haskell-openal/ALUT/tree/master/examples/Basic
>
>
> Best,
>
> Tilmann
>
>
>
>
> Am 06.10.16 um 17:17 schrieb Cleverson Casarin Uliana:
> > Hello all, is it easy to play/stop sound wave files on Windows? For
> > now I'd like just playing and stopping them assynchronously. Do I need
> > to install any package besides Haskell Platform?
> >
> > Thanks,
> > Cleverson
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 8 Oct 2016 10:54:54 -0300
> From: Cleverson Casarin Uliana <[email protected]>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <[email protected]>
> Subject: Re: [Haskell-beginners] Basic sound playing on Windows?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> Thank you Tilmann, it's quite good.
>
> Greetings,
> Cleverson
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 9 Oct 2016 10:27:22 +0800
> From: Lai Boon Hui <[email protected]>
> To: [email protected]
> Subject: [Haskell-beginners] Lazy evaluation, trying to find out when
> its done
> Message-ID:
> <CAJdQggm7L--6Wb6kdqdDiSExEn10_Q8JwWHexVsUN4-LHmB2hw@mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi all,
>
> I understand that the take method will evaluate the value inside the cons
> cell whereas length will just evaluate the spine or structure of the list
>
> λ> let y = "abc"
> Prelude|
> y :: [Char]
> λ> :sprint y
> y = _
> λ> take 1 y
> "a"
> it :: [Char]
> λ> :sprint y
> y = 'a' : _
> λ>
>
> Well and good but why doesn't the same work on a list of Nums??
>
> λ> let x = [1,2,3]
> Prelude|
> x :: Num t => [t]
> λ> :sprint x
> x = _
> λ> take 1 x
> [1]
> it :: Num a => [a]
> λ> :sprint x
> x = _
> λ>
>
> I expected to see x = 1 : _
>
> --
> Best Regards,
> Boon Hui
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.haskell.org/pipermail/beginners/
> attachments/20161009/7f08152b/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 9 Oct 2016 00:34:31 -0400
> From: Tom Murphy <[email protected]>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <[email protected]>
> Subject: Re: [Haskell-beginners] Lazy evaluation, trying to find out
> when its done
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=utf-8
>
> Maybe this will help answer some questions and raise others:
>
> . let x = [1,2,3]
> . take 1 x
> [1]
> . :sprint x
> x = _
> . let x = [1,2,3] :: [Int]
> . take 1 x
> [1]
> . :sprint x
> x = [1,2,3]
>
> Tom
>
>
> On Sun, Oct 09, 2016 at 10:27:22AM +0800, Lai Boon Hui wrote:
> > Hi all,
> >
> > I understand that the take method will evaluate the value inside the cons
> > cell whereas length will just evaluate the spine or structure of the list
> >
> > λ> let y = "abc"
> > Prelude|
> > y :: [Char]
> > λ> :sprint y
> > y = _
> > λ> take 1 y
> > "a"
> > it :: [Char]
> > λ> :sprint y
> > y = 'a' : _
> > λ>
> >
> > Well and good but why doesn't the same work on a list of Nums??
> >
> > λ> let x = [1,2,3]
> > Prelude|
> > x :: Num t => [t]
> > λ> :sprint x
> > x = _
> > λ> take 1 x
> > [1]
> > it :: Num a => [a]
> > λ> :sprint x
> > x = _
> > λ>
> >
> > I expected to see x = 1 : _
> >
> > --
> > Best Regards,
> > Boon Hui
>
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 100, Issue 7
> *****************************************
>
--
Best Regards,
Boon Hui
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161009/31a24906/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 10 Oct 2016 13:15:17 +0800
From: Lai Boon Hui <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Regarding defining cases exhaustively
Message-ID:
<CAJdQggkE5uDsb_GHPVmeB=v+7LRCOXti+VwsU645ZXbXY=y...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi all,
I have this code
myMaximumBy :: (a -> a -> Ordering) -> [a] -> a
myMaximumBy _ [] = undefined
myMaximumBy _ (x:[]) = x
myMaximumBy f (x:xs) =
case f x maxRestOfList of
GT -> x
_ -> maxRestOfList
where maxRestOfList = myMaximumBy f xs
whereby the case myMaximumBy _ [] will never happen because case
myMaximumBy _ (x:[]) = x prevents that from happening. However i will still
like to define it to keep -Wall warning from complaining.
Is using undefined acceptable or is there a better way?
--
Best Regards,
Boon Hui
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20161010/d46a3ed1/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 10 Oct 2016 08:51:52 +0200
From: Frerich Raabe <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Regarding defining cases exhaustively
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed
On 2016-10-10 07:15, Lai Boon Hui wrote:
> I have this code
>
> myMaximumBy :: (a -> a -> Ordering) -> [a] -> a
> myMaximumBy _ [] = undefined
> myMaximumBy _ (x:[]) = x
> myMaximumBy f (x:xs) =
> case f x maxRestOfList of
> GT -> x
> _ -> maxRestOfList
> where maxRestOfList = myMaximumBy f xs
>
> whereby the case myMaximumBy _ [] will never happen because case myMaximumBy
> _ (x:[]) = x prevents that from happening.
Somebody could call 'myMaximumBy' with an empty list, so as far as the
compiler (and fellow programmers) are concerned, this case can certainly
happen.
> However i will still like to define it to keep -Wall warning from
> complaining.
>
> Is using undefined acceptable or is there a better way?
If you're fine with having a partial function (i.e. which is not defined for
all possible inputs), then 'undefined' is okay. An alternative might be
myMaximumBy _ [] = error "empty list"
A nicer approach might be to make 'myMaximumBy' a total function though, i.e.
give a plausible definition even for empty lists. So, for instance, you could
declare it as
myMaximumBy :: (a -> a -> Ordering) -> [a] -> Maybe a
such that for empty lists, it yields 'Nothing'.
--
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 100, Issue 8
*****************************************