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. print [] (Lukas Lehner)
2. Re: print [] (Brandon Allbery)
3. Sorting Bank Accounts problem in Haskell (Nadav Chernin)
4. Re: print [] (Lukas Lehner)
5. Re: How Haskell Fits Into an Operating System / API
Environment (David Thomas)
----------------------------------------------------------------------
Message: 1
Date: Tue, 13 Aug 2013 16:46:04 +0200
From: Lukas Lehner <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] print []
Message-ID:
<CAL+wLLg61hP+PJgHDzkF=h6ff+1bc9bc2csnoxours+osvy...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello,
This code runs ok http://lpaste.net/91814 but only thanks to enforcing [()]
on line 12.
In GHCI
*Main> :t (List [])
(List []) :: NestedList a
and
*Main> :t flatten (List [])
flatten (List []) :: [a]
That means ghc cannot infer the type.
Is there a way how to # print flatten (List []) ?
Or even more general, print [] without enforcing the type?
Thank you
Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130813/e5e5c600/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 13 Aug 2013 10:59:09 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] print []
Message-ID:
<cakfcl4uk8g3hxogreu5v1tizgoejs+07w+-edwkkzp7g3p9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Tue, Aug 13, 2013 at 10:46 AM, Lukas Lehner <[email protected]>wrote:
> That means ghc cannot infer the type.
> Is there a way how to # print flatten (List []) ?
> Or even more general, print [] without enforcing the type?
>
If you turn on the ExtendedDefaultRules extension ( `{-# LANGUAGE
ExtendedDefaultRules #-}` pragma or `-X ExtendedDefaultRules` ghc option),
ghc will infer () for the type just as ghci does. Note that this reduces
type safety a bit, since ghc will now accept programs that have what
otherwise would be type errors.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130813/49c4140c/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 13 Aug 2013 18:05:15 +0300
From: Nadav Chernin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Sorting Bank Accounts problem in Haskell
Message-ID:
<CAE80G0LOHewjHi4U6d8YZ_5imss9Ja40Xon1UStO_7+g=wj...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I learn Haskell and i try to solve questions from SPOJ.
Currently, i try to solve problem *Sorting Bank
Accounts*<http://www.spoj.com/problems/SBANK/>
Here is my code:
*import qualified Data.Map as M*
*
*
*extractTest []=[]*
*extractTest (x:xs)=(take n xs):(extractTest (drop (n+1) xs)) where*
* n=read x*
*
*
*emp=M.empty*
*
*
*collect m []=m*
*collect m (x:xs)*
* |M.member x m =collect (M.insert x (amount+1) m) xs*
* |otherwise=collect (M.insert x 1 m) xs*
* where*
* Just amount=M.lookup x m*
*
*
*getList m=map (\(x,k)->x++" "++(show k)) (M.toList m)*
*f x=unlines$(getList (collect emp x))++[""]*
*main=getLine>>=(\x->interact$unlines.map f.take (read x).extractTest.lines)
*
*
*
The problem is that i can't finish it during 7 sec.
So i want to know is there more quick solution/method for this problem.
Thanks, Nadav
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130813/fd75d889/attachment-0001.html>
------------------------------
Message: 4
Date: Tue, 13 Aug 2013 17:08:45 +0200
From: Lukas Lehner <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] print []
Message-ID:
<CAL+wLLib=utyjmgljpz_qrjr_xh0iuwaolibemaftqvac45...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Good to know extension. And without it?
On Tue, Aug 13, 2013 at 4:59 PM, Brandon Allbery <[email protected]>wrote:
> On Tue, Aug 13, 2013 at 10:46 AM, Lukas Lehner <[email protected]>wrote:
>
>> That means ghc cannot infer the type.
>> Is there a way how to # print flatten (List []) ?
>> Or even more general, print [] without enforcing the type?
>>
>
> If you turn on the ExtendedDefaultRules extension ( `{-# LANGUAGE
> ExtendedDefaultRules #-}` pragma or `-X ExtendedDefaultRules` ghc option),
> ghc will infer () for the type just as ghci does. Note that this reduces
> type safety a bit, since ghc will now accept programs that have what
> otherwise would be type errors.
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> 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/20130813/f3c802b6/attachment-0001.html>
------------------------------
Message: 5
Date: Tue, 13 Aug 2013 08:21:25 -0700
From: David Thomas <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] How Haskell Fits Into an Operating
System / API Environment
Message-ID:
<CAJUDvcghq=8KR-YGHE79ukd4ruqEqsip1co3yrnB=6tkxct...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
It seems like it would be roughly as easy to encode TCP with continuations
as with the usual imperative approaches, though I'll certainly admit I
haven't tried.
On Mon, Aug 12, 2013 at 9:45 PM, damodar kulkarni <[email protected]>wrote:
>
> Curiously, whenever I use state, my programs start to become similarly
>> brittle. There is no reason why state should be a fundamental element of a
>> programming language, and as a design pattern, state is best avoided at all
>> cost.
>
>
> Just as a curiosity, how would one avoid state in cases like protocol
> design? e.g. protocols specifications (like TCP/IP) do have a large element
> of state dependent behavior that "seems essential" to the problem. How
> would one deal with such cases?
>
> @Philippe Sismondi:
>
>
> I always feel as though I am using the robot arm on a space shuttle when a
>> screwdriver would do.
>
>
> +1 for this remark.
>
> Thanks and regards,
> -Damodar Kulkarni
>
>
> On Mon, Aug 12, 2013 at 2:53 PM, Heinrich Apfelmus <
> [email protected]> wrote:
>
>> Philippe Sismondi wrote:
>>
>>>
>>> Upon reflection, probably my real concern is not about mixing
>>> dissimilar programming languages, but about the frequently discussed
>>> issue of finding production-quality libraries for a language. [..]
>>>
>>>
>>> For most of the software that I am interested in working on, there is
>>> a vast collection of "native" stuff available in both OS X and
>>> Windows. This includes, just as an example, Core Audio in OS X. [..]
>>>
>>>
>>> Moreover, I am dissatisfied with the quality of Haskell libraries
>>> even for those things that are not already supplied by OS vendors. In
>>> my opinion (and I may be wrong), hackage is littered with half-baked
>>> stuff, poorly documented projects started by extremely bright grad
>>> students and then abandoned after a year or two. (Of course, there is
>>> some great stuff on there too.)
>>>
>>
>> Well, there are a lot of magazines at the news kiosk, too, while only a
>> few are of outstanding quality. That is just how a news kiosk works.
>>
>> Speaking of quality, what I like most about Haskell libraries, even the
>> half-baked ones, is that they have very few bugs. I've been programming
>> functionally for a decade now, and whenever I venture into the world of
>> imperative languages, I always trip up bugs that just shouldn't be there.
>> Here two recent examples:
>>
>> * HTML 5 drag and drop. Apart from the fact that the specification is
>> overcomplicated, Chrome doesn't even implement the spec correctly. When the
>> mouse enters a child element of a "dropzone'd" element, the latter receives
>> a "dragleave" event, but will not receive a "dragenter" event again when
>> the mouse moves away from the child element. Argh!
>>
>> * HTML 5 WebSockets. Chrome or Safari. After a certain amount of
>> inactivity on the server side, the browser will close the WebSocket.
>> However, it will only close the client side, so the client cannot send
>> messages anymore. The connection to the server is still *open*, though, and
>> the server can happily send data. What? Also, if you connect with a
>> WebSocket and then reload the page and connect again, the old connection
>> will be reused. WTF?
>>
>> These are just examples, this happens to me all the time. Curiously,
>> whenever I use state, my programs start to become similarly brittle. There
>> is no reason why state should be a fundamental element of a programming
>> language, and as a design pattern, state is best avoided at all cost.
>>
>>
>> As a result of this little thread I have come to another conclusion,
>>> and this is just my subjective view. Most of the software that I am
>>> interested in seems to live most comfortably with a stateful
>>> conception of the world. (The native libraries I find most useful
>>> certainly are stateful.) I am reasonably competent with monads and
>>> monad transformers in Haskell. But, to be honest, after three years
>>> of pluggin away at Haskell, I am not the least convinced that the
>>> problem of handling a changing external world in a pure functional
>>> language has been successfully solved by those techniques. I always
>>> feel as though I am using the robot arm on a space shuttle when a
>>> screwdriver would do. (Again, no need to rebut this - I may be wrong
>>> or just to stupid to use Haskell effectively - so be it.)
>>>
>>> Perhaps in the end I do not really believe that functional
>>> programming is the panacea that its devotees claim it to be.
>>>
>>> I think this post may mark the beginning of my abandonment of Haskell
>>> for many purposes.
>>>
>>
>> Haskell may not be easy to learn, but it's definitely worth the effort.
>>
>>
>>
>> Best regards,
>> Heinrich Apfelmus
>>
>> --
>> http://apfelmus.nfshost.com
>>
>>
>> ______________________________**_________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>>
>
>
> _______________________________________________
> 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/20130813/54c6c85a/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 62, Issue 14
*****************************************