
GHC 7.8.1 released - ocharles
http://www.haskell.org/pipermail/haskell/2014-April/024137.html
======
swift
I don't recall ever being excited about a compiler release before, but this
has got me excited. Typed holes, overloaded lists, pattern synonyms, new IO
manager, new code generator, interruptible FFI calls, parallel compilation,
and tons of other new features.

One thing I'm particularly excited about is the switch to use the system's
dynamic linker instead of a custom one in GHCi. The custom linker GHCi used
before didn't support some features used by C++ code, which meant that some of
my FFI-based projects weren't usable in GHCi. This also affected other things
that used a GHCi-like code path like Template Haskell and the GHC APIs used by
ghc-mod/hdevtools. This will be _huge_ for usability for me when working on
projects that link to C++.

Hat tip to all the GHC developers for a truly amazing release!

~~~
thoughtpolice
The dynamic switch isn't without its pain points. In particular, the way we
currently implement it leaves some things to be desired, and it's lead to some
other rather unfortunate ramifications for Windows right now.

Truthfully, me and Simon now have reservations about if this is the right way
to go, and we should instead invest more infrastructure into our own Linker
(which, independently, got some nice bug fixes this time around - constructors
and weak pointers now work, for example.) ELF support is quite complete (and
very stable) for example. It's just a question of what's the most work.

------
reirob
[..]
[http://www.haskell.org/ghc/docs/7.8.1/html/users_guide/type-...](http://www.haskell.org/ghc/docs/7.8.1/html/users_guide/type-
class-extensions.html#overloaded-lists) [..]

This extension allows programmers to use the list notation for construction of
structures like: Set, Map, IntMap, Vector, Text and Array. The following code
listing gives a few examples:

['0' .. '9'] :: Set Char

[1 .. 10] :: Vector Int

[("default",0), (k1,v1)] :: Map String Int

['a' .. 'z'] :: Text

[http://www.haskell.org/ghc/docs/7.8.1/html/users_guide/type-...](http://www.haskell.org/ghc/docs/7.8.1/html/users_guide/type-
class-extensions.html#overloaded-lists)

~~~
tel
Woah! I did not know that was going to be included! Here's to hoping it makes
as much a splash as OverloadedStrings did!

~~~
IsTom
As a non-fan of OverloadedStrings, I'm not sure how I feel about this.

~~~
dllthomas
What are your objections to OverloadedStrings?

~~~
chongli
It can give unexpected/wrong results when working with Unicode strings.

~~~
hesselink
Can you elaborate? Perhaps you are talking about the Char8 ByteString
instance? It was a mistake to declare that instance, I think.

~~~
chongli
_Perhaps you are talking about the Char8 ByteString instance?_

Yes. _Data.ByteString.Char8.pack_ does not form an isomorphism with
_Data.ByteString.Char8.unpack_. It is thus not interchangeable with String.

Example:

    
    
        Prelude Data.ByteString.Char8> putStrLn . unpack . pack $ "Российская Федерация"
        >AA89A:0O $545@0F8O
    

And here the correct result with Data.Text:

    
    
        Prelude Data.Text> putStrLn . unpack . pack $ "Российская Федерация"
        Российская Федерация

~~~
startling
That's an issue with Data.ByteString.Char8, not with OverloadedStrings.

~~~
chongli
When you use OverloadedStrings in conjunction with Data.ByteString.Char8 it
becomes OverloadedStrings' issue as well. Compile-time transformations are not
supposed to break your program.

~~~
tel
I don't think of it as a compile-time transformation but instead a weakening
of the semantics of string literals. Without we have

    
    
        "foo" :: String
    

and with we have

    
    
        "foo" :: IsString a => a
    

much like

    
    
        3 :: Num a => a
    

It inherits all of the same weaknesses and strengths that we have with the Num
typeclass.

~~~
chongli
Ahh, very good. Then perhaps our target of inquiry ought to be the IsString
class. Ought it have some laws we can expect instances to follow, akin to the
Monad laws? At the moment, we can write:

    
    
        instance IsString () where
        fromString = const ()
    

And there's nothing wrong with it!

~~~
tel
Totally agree that it's a weak class. I'd love it if `IsList` were a subclass
of `Foldable`!

------
chowells
I've been playing around with the new PatternSynonyms extension. In
combination with the existing ViewPatterns extension, I'm going to really have
to change the way I think about API design. This is actually pretty fantastic.

    
    
        {-# LANGUAGE ViewPatterns, PatternSynonyms #-}
        
        import Data.Set as S
        
        -- patterns that a library might provide
        pattern x :< m <- (minView -> Just (x, m))
        pattern m :> x <- (maxView -> Just (x, m))
        pattern Null   <- (S.null  -> True)
        
        -- a really dumb test function using those patterns
        doubleMin :: (Ord a, Num a) => Set a -> Set a
        doubleMin (x :< s) = insert (2 * x) s
        doubleMin x = x
    

Ignore how dumb my test function is, and just focus on how lightweight it
becomes to match views of the data structure. Figuring out what patterns to
include my libraries is going to be a fun new design point.

~~~
axman6
I haven't had a look at the extension definition itself, but I find this
really hard to read. Can you or someone else give an explanation of what's
going on? It seems to me that the brackets are all wrong, I would've expected

    
    
        pattern (x :< m <- minView) -> Just (x,m)
    

but that's just basically view patterns/pattern guards. Basically I can sort
of see what's going on here, but only in this specific case; I can't see how
one uses this elsewhere.

~~~
chowells
The choice of character for unidirectional patterns isn't the greatest, I'll
agree.

The PatternSynonyms extension enables two new top-level declarations, both
declared with "pattern".

    
    
        pattern NestedJust x = Just (Just x)
        pattern NestedNothing = Just Nothing
    

That's the easier syntax of a bidirectional pattern synonym. They can be used
both as patterns and as expressions.

    
    
        foo :: Maybe (Maybe Int) -> Bool
        foo (NestedJust 7)  = True
        foo (NestedNothing) = False
        foo _               = False
    
        bar :: Maybe (Maybe String)
        bar = NestedJust "hello"
    

There are a couple terrible examples. Bidirectional pattern synonyms must be
valid as both expressions and pattern matches, or you get a compile error

My example was using unidirectional pattern synonyms. They allow any pattern
match whatsoever as the body; the expression restriction is dropped because
they aren't allowed to be used in expression contexts. They are defined using
<\- instead of =.

    
    
        pattern MinView x m <- (minView -> Just (x, m))
    

That's functionally the same as the :< example above, but possibly a bit
simpler to read, because the precedence of the symbols is more obvious. It
defines a pattern synonym named MinView that is translated to the view pattern
in parens.

It's quite possible you were conflating view pattern syntax with pattern guard
syntax as the source of your confusion.

------
carterschonwald
For those who write large scale applications, web or otherwise, the mio io
manager improvements should be especially exciting. See
[http://www.reddit.com/r/haskell/comments/1k6fsl/mio_a_highpe...](http://www.reddit.com/r/haskell/comments/1k6fsl/mio_a_highperformance_multicore_io_manager_for/)
for a prior discussion.

~~~
hamidr
I was reading the paper and got stuck somewhere when I saw this:

> With Mio, realistic HTTP servers in Haskell scale to 20 CPU cores, achieving
> peak performance up to factor of 6.5x compared to the same servers using
> previous versions of GHC. The latency of Haskell servers is also improved:
> <snip> under a moderate load, reduces expected response time by 5.7x when
> compared with previous versions of GHC

> Available with GHC 7.8.1

Nice job.

------
Sir_Cmpwn
I really want to get into Haskell, but I just don't understand it. The
tutorial on the official site doesn't do it for me. Can anyone suggest
alternative resources for learning? I'm used to C-like languages.

Thanks for all the responses. I'll start with LYAH.

~~~
nnq
I sincerely recommend against LYAH! It takes sooooooooo loooooong to get to
the interesting bits that actually make Haskell worth learning an has so many
try-to-be-funny examples that it makes you run away screaming... I tried going
through it but it was literally oscillating between putting my mind to sleep
and making wish to grab a chainsaw :) And the "humor" and "pretty pictures"
don't help either... they were more like poignant guide to ruby, something
that you either love or they annoy the hel out of you (this was for me), but
either way they don't help the learning experience at all.

I suggest HFH ("Haskell Fast & Hard") as _the_ introductory tutorial to start
with instead. You can pick from 2 formats:

\- [http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-
Way...](http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/) \-
static all-in-one-page format with pretty pictures

\- [https://www.fpcomplete.com/school/to-infinity-and-
beyond/pic...](https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-
of-the-week/haskell-fast-hard) \- split version, but with the ability to open
snippets in their web based IDE

...after this, Real World Haskell is probably the next step:
[http://book.realworldhaskell.org/read/](http://book.realworldhaskell.org/read/)
(I'm still at this step).

~~~
rando289
I accidentally upvoted you, but I disagree. LYAH is a great book to actually
read through, and I enjoyed the humor. real world haskell introduces things
without explaining and it's quite confusing and inconsistent.

~~~
pestaa
Why would downvote for disagreeing? GP is actually a well written comment, and
very much deserves the upvote.

------
Osmium
I'm intrigued by "full iOS support." Does this mean it's now possible to write
iOS apps using a Haskell backend?

~~~
thinkpad20
I'm also intrigued. How would one program for iOS in a practical sense with
Haskell? A great deal of iOS programming, as I understand it, is navigating
the APIs and libraries provided by the SDK... is this a simple task in
Haskell? The FFI is something I haven't really dealt with much yet. I guess
people could/will start writing wrapper libraries?

~~~
JoshTriplett
Haskell has one of the best FFIs I've ever seen; calling C code from Haskell
is quite trivial, and you can write all of the necessary wrapper code and
objects (such as automatic memory management or object destruction) in Haskell
using common wrappers.

I'd also highly recommend c2hs for writing new wrapper libraries.

~~~
lucian1900
Part of the problem is that iOS APIs tend to be Objective-C, which is somewhat
harder to wrap in Haskell.

~~~
gregschlom
Not really, it's quite easy to call Objective-C methods (or more correctly, to
send messages to Objective-C selectors) and perform other Objective-C-related
tasks from C. See:
[https://developer.apple.com/library/mac/documentation/Cocoa/...](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html)

This is actually what the Objective-C compiler does. It translates your
Objective-C code to C method calls.

~~~
chc
It's not _that_ easy. I mean, just sending a message could entail one of
objc_msgSend, obj_msgSend_stret or objc_msgSend_fpret, and which one you want
to use is not always as clear-cut as you might prefer
([http://www.sealiesoftware.com/blog/archive/2008/10/30/objc_e...](http://www.sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend_stret.html)).
And then there's the hassle of defining classes dynamically, which entails six
function calls just to create a class with one empty method, and one of those
essential functions is not actually provided for you AFAIK unless you're using
Apple's compiler where it's a builtin, so you'll need to write it yourself.

It's not ridiculously hard, but it's somewhat less easy than normal C FFI.

~~~
iand675
The other hard part about it is that Haskell's FFI doesn't support variadic
functions in a friendly way, which makes argument passing that much trickier.

~~~
chc
There is a similar problem with objc_msgSend in C: Methods with certain
argument types can't be called with a normal objc_msgSend(). Instead, you need
to create a specifically typed function pointer and assign objc_msgSend to it.
I think a similar solution would be necessary with Haskell.

~~~
iand675
I'd appreciate seeing a link to an example of this. I put a decent amount of
work (a few years ago) into writing some bindings in Haskell to the objc
runtime, but ended up shelving it until I could come up with a satisfactory
solution to the variadic function dilemma.

~~~
chc
Here are a couple of Stack Overflow answers that illustrate how you do it in
Objective-C:

[http://stackoverflow.com/a/2573949](http://stackoverflow.com/a/2573949)

[http://stackoverflow.com/a/18689338](http://stackoverflow.com/a/18689338)

If you're interested in the nitty-gritty of how objc_msgSend works, bbum from
Apple wrote up a great low-level walkthrough a few years back:
[http://www.friday.com/bbum/2009/12/18/objc_msgsend-
part-1-th...](http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-the-
road-map/)

------
BSousa
I know enough about Haskell to be excited, but recently, I implemented a few
systems with F# and am really happy with the language. If we forget about the
.net/MS thing (and all the hatred that comes from that), are there real true
advantages of going Haskell for a greenfield project over F# ? (I have a
couple heavy algorithm heavy Haskell projects done, but having worked with F#
more and more, I feel like it is so much nicer as a modern, not bend over your
back to deal with the purity/lazy aspects language than Haskell).

------
carterschonwald
One really cute feature that some systems folks might like is there's now
support for calling the CPU/hardware prefetch instruction where applicable.
[http://www.haskell.org/ghc/docs/7.8.1/html/libraries/ghc-
pri...](http://www.haskell.org/ghc/docs/7.8.1/html/libraries/ghc-
prim-0.3.1.0/GHC-Prim.html#g:28)

~~~
sanxiyn
Even better, if you use vector library, prefetch instructions are
automatically (and nearly optimally) inserted for your loops written in
higher-order functions like fold.

Details here: [http://research.microsoft.com/en-
us/um/people/simonpj/papers...](http://research.microsoft.com/en-
us/um/people/simonpj/papers/ndp/)

~~~
carterschonwald
Nope. That's not in the release version. Simd is still second class in ghc.
Should be viable for ghc 7.10 though. Note well, the prefetches in that paper
aren't optimal. In many cases prefetch is over issued.

You should only use prefetch when benchmarks show that the hardware prefetch
isn't performing up to sniff. Or when your access pattern for data doesn't
have good locality and doesn't resemble a linear arithmetic sequence. (Just
rules of thumbs mind you. For more precise heuristics, please read your CPU
vendors optimization manual. The intel manual has quite a few tricks that
should apply to most modern CPUs overall)

------
dbbolton
A bit off topic- why is GHC so large? I recently noticed it was over three
times the size of gcc (for amd64, in an .xz archive).

~~~
thinkpad20
This might be interesting to you:
[http://stackoverflow.com/questions/4858585/why-is-ghc-so-
lar...](http://stackoverflow.com/questions/4858585/why-is-ghc-so-large-big)

~~~
jeorgun
Now I'm kind of curious. The GHC is listed there as being 113 megabytes. When
I try to install it on Arch Linux, the size is listed as 736MB! What in God's
name is Arch doing to nearly septuple the size of this package— and more to
the point, does anyone know any way of getting it to _not_ do that? I'd very
much like to learn Haskell, but taking up that much space on my laptop's SSD
is a dealbreaker.

~~~
thoughtpolice
That's because they're measuring the tarball, which is a worthless metric
anyway (for example, we just switched to supporting .tar.xz, which reduced the
size of Linux binary distributions close to 50% for a ~65MB total. But that
doesn't tell you anything about what's inside.)

The unpacked binary distribution is closer to 1GB, which sounds about right. I
speculate Arch Linux is doing a regular build with nothing special.

If 1GB is undoable for your laptop (which I find odd, as someone even on a
100GB device), then that's unfortunate. You're best to wait for some other
build with things removed or to just build it yourself (for example, no
dynamic linking).

------
izietto
I want to find a job as Haskell programmer!

~~~
dllthomas
I've projects I'd be willing to delegate, if I can pay you sufficiently
little...

~~~
jc79
Sharing izietto's wish, how might one contact you?

~~~
dllthomas
You can shoot me an email (davidleothomas@gmail.com) or hit me on irc
(davidthomas on freenode - I typically lurk in #haskell and #snowdrift,
amongst other places). I don't want to get hopes up too high - sufficiently
little isn't going to be much in the short term.

------
tree_of_item
Is GHCJS easy to install now? I'm very excited about that.

~~~
carterschonwald
Luite is probably going to announce something like that in a few days. Ghcjs
getting ready for general release was blocked by ghc 7.8.1 not being released.

------
ciferkey
Great! Can't wait until the next release of the Haskell Platform now.

~~~
chowells
Don't.

There's no benefit to handcuffing yourself to the platform. Just install ghc
and cabal, and enjoy yourself.

~~~
lomnakkus
... and use cabal sandboxes! Otherwise the "enjoy yourself" bit may be a
little short-lived ;)

------
masida
What will be the easiest way to get GHC 7.8.1 running alongside the official
GHC packages for Debian (specifically Jessie)?

Should I download a package from
[http://deb.haskell.org/](http://deb.haskell.org/)? If so, where can I find
7.8.1?

~~~
jberryman
The binary distributions install alongside your system packages or other
bindists quite nicely (they might overwrite the /usr/bin/ghc symlink, but
that's it) and you can select which ghc version you want to use when using
cabal with the `-w` flag. Each will keep a separate package db, etc. So be
bold!

~~~
masida
Thank you for your comment. I've ended up installing 7.8.1 from the binary
distributions from the GHC site:
[http://www.haskell.org/ghc/download_ghc_7_8_1](http://www.haskell.org/ghc/download_ghc_7_8_1)

As easy as:

    
    
      tar -xJvf ghc-7.8.1-i386-unknown-linux-deb7.tar.xz
      cd ghc-7.8.1
      ./configure --prefix=/opt/ghc-7.8.1
      make install

------
Avalaxy
This is great news for all 5 haskell programmers!

Just kidding, Haskell is a great language, it's unfortunate that the tooling
is still way behind (at least on Windows) and that it isn't used much.

