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: FRP (Ertugrul S?ylemez)
2. an observation about Haskell vs. Python (Dennis Raddle)
3. Re: an observation about Haskell vs. Python (Ertugrul S?ylemez)
4. Re: an observation about Haskell vs. Python (Alexander Bernauer)
5. Strange new Haskell Platform (bucephalus org)
6. Re: Strange new Haskell Platform (Chadda? Fouch?)
----------------------------------------------------------------------
Message: 1
Date: Thu, 20 Sep 2012 04:56:05 +0200
From: Ertugrul S?ylemez <[email protected]>
Subject: Re: [Haskell-beginners] FRP
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Miguel Negrao <[email protected]> wrote:
> > Netwire follows a more algebraic path and drops the classic notion.
> > The line between signals and events is blurred. It's a bit more
> > difficult to understand, but is more expressive and concise. Also
> > it's pretty much time-leak-free. The library is designed to be very
> > elegant while preserving non-FRP performance to a high degree.
> >
> > (To be fair, I'm the author of Netwire.) =)
>
> Having recently looked a bit on Yampa, what are the main differences
> between Yampa and Netwire ?
The way events are handled. Yampa uses the classic automaton category
with an additional time delta argument for its signal function
representation (Yampa's type is more complicated, but isomorphic to this
one):
type Time = Double
newtype SF a b = SF (Time -> a -> (b, SF a b))
Netwire generalizes this category to a class of wire categories
(simplified and without associated types):
newtype Wire e a b = Wire (Time -> a -> (Either e b, Wire e a b))
SF is an arrow and an applicative functor (although Yampa does not
provide an Applicative instance). Wire is also an Alternative, which
allows concise and efficient switching with very little cruft. The
following wire renders "yes" when the "keyDown Space" event happens and
"no" otherwise:
pure "yes" . keyDown Space <|> pure "no"
Or with the OverloadedStrings extension:
"yes" . keyDown Space <|> "no"
All classic (non-wire) FRP implementations need switching or another
ad-hoc combinator for this. If you happen to need switching it's also a
lot simpler using wires:
"please press space" . notE (keyDown Space) --> "thanks"
This one waits for the Space key and then outputs "thanks" forever. So
far Netwire has the fastest and most elegant way of dealing with events
compared to all other libraries I have tried.
Greets,
Ertugrul
--
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120920/e81ff3b9/attachment-0001.pgp>
------------------------------
Message: 2
Date: Wed, 19 Sep 2012 20:33:12 -0700
From: Dennis Raddle <[email protected]>
Subject: [Haskell-beginners] an observation about Haskell vs. Python
To: Haskell Beginners <[email protected]>
Message-ID:
<cakxlvor4tfzi-zseocp8tgy+gxyy5dqvfheg73k3mzdad_k...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Thanks. I'm okay with the status quo.. I just see it as a tradeoff. You are
giving up something to get something. In Python you give up any kind of
compile-time type checking, you give up the safety of immutable data, and
you get a whole lot of automatic type conversions and brief ways to express
certain algorithms. In Haskell you give up easy-to-comprehend error
messages and mutable data, and get back in reward a lot of reassurance that
your program does what you meant and expressivity. (I realize Haskell has
mutable data but it's not like Python's)
On Wed, Sep 19, 2012 at 7:43 PM, Ertugrul S?ylemez <[email protected]> wrote:
>
> Notice: You probably forgot to apply `sin' to an argument.
>
> However, I think that no work is done on that, and there is another
> possible path: An average Haskell tutorial should always include a
> section on understanding error messages. In fact the latest issue of
> The Monad Reader [1] has an article on that by Jan Stolarek.
>
> [1]: http://themonadreader.files.wordpress.com/2012/08/issue20.pdf
>
>
> Greets,
> Ertugrul
>
> --
> Not to be or to be and (not to be or to be and (not to be or to be and
> (not to be or to be and ... that is the list monad.
>
> _______________________________________________
> 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/20120919/11877354/attachment-0001.htm>
------------------------------
Message: 3
Date: Thu, 20 Sep 2012 06:23:39 +0200
From: Ertugrul S?ylemez <[email protected]>
Subject: Re: [Haskell-beginners] an observation about Haskell vs.
Python
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Dennis Raddle <[email protected]> wrote:
> [...] In Haskell you give up easy-to-comprehend error messages and
> mutable data, and get back in reward a lot of reassurance that your
> program does what you meant and expressivity. (I realize Haskell has
> mutable data but it's not like Python's)
It is actually the same. It's just that the assignment function is not
called "=", but instead, say, writeSTRef. You could very well give it
an additional name, e.g. "~=":
class Mutable m where
type Ref m :: * -> *
newRef :: a -> m (Ref m a)
(~=) :: Ref m a -> a -> m ()
instance Mutable IO where
type Ref IO = IORef
newRef = newIORef
(~=) = writeIORef
main = do
x <- newRef 10
x ~= 15
{- ... -}
In fact Haskell generalizes this idea, because using lenses you can have
something similar even in state monads, which are actually pure and
don't use mutable variables.
Also I really doubt that there is any algorithm that has a shorter
and/or more readable implementation in Python from a language viewpoint.
It's really more a matter of what is predefined.
Greets,
Ertugrul
--
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120920/c859dcc5/attachment-0001.pgp>
------------------------------
Message: 4
Date: Thu, 20 Sep 2012 09:03:11 +0200
From: Alexander Bernauer <[email protected]>
Subject: Re: [Haskell-beginners] an observation about Haskell vs.
Python
To: Haskell Beginners <[email protected]>
Message-ID: <20120920070311.GG3324@apus>
Content-Type: text/plain; charset="us-ascii"
On Wed, Sep 19, 2012 at 06:24:35PM -0700, David Hinkes wrote:
> With python (and any other non-compiled language for that matter) the unit
> testing is very important. I almost think of the unit tests as the
> compiler (does that make sense to anyone but me?).
IMO this doesn't make sense for several reasons:
1) Just because a Haskell program compiles it is not magically correct
with respect to what it is _supposed_ to do. So you still need unit
testing in Haskell [1,2,3,4] - but you can focus more on functionality
rather than typos, lapses and structures.
2) Covering all "type errors" with Python unit testing is hard and
cummbersome. In the OP's words this means that you write your dedicated
"compiler" for every single project.
3) Concluding the "type error" from a failed Python unit test is not
trivial, especially because the reported error points to the location
of the failure as opposed to the location of the fault.
4) Setting up unit tests for non-pure functions is quite an effert
because the environment has to be brought into the right state first.
Also, the environment's state has to be checked afterwards (i.e.
mocking, virtual environments, etc.)
5) Running all unit tests usually takes _much_ longer than running the
type checker (especially due to 4)
I did quite some Python hacking in the past and although I still like
the language, I love Haskell's type inference. Feels almost like
scripting but allows for even faster development in the end, because
you save time writing unit tests (2,4), "type errors" are detected faster
(5) and finding the fault is quicker (3). Not to mention refactoring.
Greetings
Alex
PS: For this post, I am calling "type errors" the set of bugs that the
Haskell type checker can detect. Not a very precise definition, but I
hope you get the idea.
[1] http://hackage.haskell.org/package/HUnit-1.2.5.1
[2] http://hackage.haskell.org/package/QuickCheck-2.5
[3] http://hackage.haskell.org/package/test-framework-0.6.1
[4] http://book.realworldhaskell.org/read/testing-and-quality-assurance.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120920/7a4f850d/attachment-0001.pgp>
------------------------------
Message: 5
Date: Thu, 20 Sep 2012 10:18:26 +0200
From: bucephalus org <[email protected]>
Subject: [Haskell-beginners] Strange new Haskell Platform
To: [email protected]
Message-ID:
<CAJ6-dtrNZDA7z8P6W8=sutgm6eozaty6sbg1hovyyw+cmqh...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Dear fellow Haskellers,
last weak my Linux machine broke down and refused to start again. I bought
a new one and installed a fresh new KDE/Linux distribution (Mint/Ubuntu)
and it looks and feels awesome. I also installed the Haskell platform via
the default GUI installer (mintInstall).
But when I try to run my recovered Haskell modules again, strange things
happen.
First of all, I have a module that has a line
import System
and that used to be fine. But now, when I try to load the module in a ghci
session, I get a complaint:
Could not find module 'System'
It is a member of the hidden package 'haskell98-2.0.0.1'
...
The same happens if I do a
Prelude> :m System
What is going on?
Secondly, I have another module that has a data type definition like this
data (Show n, Show v, Ord n, Ord v) => Automaton n v = Automaton {
nameSet :: Set.Set n,
valueSet :: Set.Set v,
....
} deriving (Show, Eq, Ord)
and that used to work fine, too. But now, I get the complaint
Illegal datatype context (use -XDatatypeContexts): (Show n, Show v, Ord
n, Ord v) =>
But when I follow the advice and start the module file with a
{-# LANGUAGE DatatypeContexts ... #-}
I got the opposite complaint:
Warning: -XDatatypeContexts is depracated: It was widely considered a
misfeature, and has been removed from the Haskell language.
How can I clean this up?
Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120920/d7d61afe/attachment-0001.htm>
------------------------------
Message: 6
Date: Thu, 20 Sep 2012 10:58:14 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] Strange new Haskell Platform
To: bucephalus org <[email protected]>
Cc: [email protected]
Message-ID:
<CANfjZRY9B2mbf+MvsZEF=9kvskkp7z+hvw2por_-fpp2wvg...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Thu, Sep 20, 2012 at 10:18 AM, bucephalus org
<[email protected]>wrote:
> Dear fellow Haskellers,
>
> last weak my Linux machine broke down and refused to start again. I bought
> a new one and installed a fresh new KDE/Linux distribution (Mint/Ubuntu)
> and it looks and feels awesome. I also installed the Haskell platform via
> the default GUI installer (mintInstall).
> But when I try to run my recovered Haskell modules again, strange things
> happen.
>
That's because your reinstalled Haskell Platform is more recent than your
old one, it brings a new version of GHC (7.4.1 probably) and this version
has moved from Haskell 98 to Haskell 2010 for its defaults.
>
>
> First of all, I have a module that has a line
> import System
> and that used to be fine. But now, when I try to load the module in a ghci
> session, I get a complaint:
> Could not find module 'System'
> It is a member of the hidden package 'haskell98-2.0.0.1'
> ...
> The same happens if I do a
> Prelude> :m System
> What is going on?
>
>
Haskell 2010 makes official the move from the old flat module namespace to
the semi-hierarchical modules names so what used to be in System is now in
System.Environment/Exit/.. you usually only need one. If you still want to
use the old Haskell98 modules, you can expose the package haskell98 (which
you do by adding "-package haskell98" to the command line or adding the
package in the .cabal file)
>
> Secondly, I have another module that has a data type definition like this
> data (Show n, Show v, Ord n, Ord v) => Automaton n v = Automaton {
> nameSet :: Set.Set n,
> valueSet :: Set.Set v,
> ....
> } deriving (Show, Eq, Ord)
> and that used to work fine, too. But now, I get the complaint
> Illegal datatype context (use -XDatatypeContexts): (Show n, Show v, Ord
> n, Ord v) =>
> But when I follow the advice and start the module file with a
> {-# LANGUAGE DatatypeContexts ... #-}
> I got the opposite complaint:
> Warning: -XDatatypeContexts is depracated: It was widely considered a
> misfeature, and has been removed from the Haskell language.
> How can I clean this up?
>
>
Basically the context in "data (Show n, Show v, Ord n, Ord v) => Automaton
n v" don't do what one would typically want it to do, that is it doesn't
add it implicitly in functions that use the Automaton type, you have to do
that yourself. So the Haskell committee decided to deprecate this
misleading possibility, most people would do fine without (eventually
documenting the expectations in an Haddock comment) or use GADTs instead
that really works for those kind of things. So either you delete this (Show
n...) context (moving it to documentation) which shouldn't have any effect
on your program (major reason for this deprecation) or you just ignore the
deprecation warning (it's just a warning after all).
It's a brand new world ! And to compensate for those little problems, this
new GHC probably compiles faster programs than your old one and offer some
interesting new capacities (see the release notes).
--
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120920/c53f12a0/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 51, Issue 30
*****************************************