Daniel Santa Cruz | 7 Feb 02:30 2013
Picon

Haskell Weekly News: Issue 257

Welcome to issue 257 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of January 27 to February 02, 2013.

Quotes of the Week

   * shachaf: Everyone forgets about Agda Lovelace, the first
     constructivist.

   * applicative: I have my new ghc and am reinstalling my feeble world

   * wuttf: My world is starting to feel like isToyLanguage x = x /=
     Haskell

   * PenguinOfDoom: Being enlightened gentlemen, we split all
     programming languages into two groups, sucks and doesn't-suck and
     put all of them into the first group.

   * Taneb: lens has got to be the only library with more contributors
     than people who know how it works

   * shachaf: I like to put all my application's modules under GHC.*
     That's because I use the GHC API, and I want them not to conflict.

Top Reddit Stories

   * The FP Complete School of Haskell goes beta
     Domain: fpcomplete.com, Score: 84, Comments: 45
     On Reddit: [1] http://goo.gl/dEEyU
     Original: [2] http://goo.gl/0eKLt

   * My reaction to: How To Exclude Women From Your Technical Community: A Tutorial
     Domain: self.haskell, Score: 75, Comments: 145
     On Reddit: [3] http://goo.gl/dVnVv
     Original: [4] http://goo.gl/dVnVv

   * Edward Yang: The GHC scheduler
     Domain: blog.ezyang.com, Score: 72, Comments: 1
     On Reddit: [5] http://goo.gl/pkCmD
     Original: [6] http://goo.gl/SP1s3

   * GHC HEAD now has support for named holes; an extension of -XTypeHoles. Feedback welcome!
     Domain: github.com, Score: 44, Comments: 32
     On Reddit: [7] http://goo.gl/87Pbw
     Original: [8] http://goo.gl/cqX9N

   * LiquidHaskell - Safely Catching A List By Its Tail
     Domain: goto.ucsd.edu, Score: 44, Comments: 2
     On Reddit: [9] http://goo.gl/uxU64
     Original: [10] http://goo.gl/9aS35

   * ProseDoc: A literate programming tool for Haskell inspired by docco
     Domain: shangaslammi.github.com, Score: 43, Comments: 12
     On Reddit: [11] http://goo.gl/x4YGE
     Original: [12] http://goo.gl/sM4bN

   * ANNOUNCE: GHC version 7.6.2
     Domain: haskell.org, Score: 39, Comments: 16
     On Reddit: [13] http://goo.gl/BS6Sm
     Original: [14] http://goo.gl/RPF00

   * What you consider "advanced" Haskell topics?
     Domain: self.haskell, Score: 34, Comments: 45
     On Reddit: [15] http://goo.gl/JRgzG
     Original: [16] http://goo.gl/JRgzG

   * How to write unmaintainable Haskell code
     Domain: github.com, Score: 34, Comments: 49
     On Reddit: [17] http://goo.gl/V0nxC
     Original: [18] http://goo.gl/G8wNv

   * Introduction to Haskell, Lecture 3 is Live (Types and Typeclasses)
     Domain: shuklan.com, Score: 32, Comments: 5
     On Reddit: [19] http://goo.gl/JyH81
     Original: [20] http://goo.gl/bve7N

   * Proposal: A trivial Cabal package signing utility for use with Hackage
     Domain: github.com, Score: 32, Comments: 61
     On Reddit: [21] http://goo.gl/R2l9g
     Original: [22] http://goo.gl/IpYSo
  
Top StackOverflow Questions

   * Haskell/GHC UndecidableInstances - example for non-terminating type check?
     votes: 19, answers: 2
     Read on SO: [23] http://goo.gl/KX8oj

   * Efficient parallel strategies
     votes: 15, answers: 2
     Read on SO: [24] http://goo.gl/aDnW2

   * Is it possible to implement MonadFix for `Free`?
     votes: 15, answers: 2
     Read on SO: [25] http://goo.gl/uKOrO

   * Do Haskell imports have side effects?
     votes: 15, answers: 1
     Read on SO: [26] http://goo.gl/sjltX

   * What monads can be expressed as Free over some functor?
     votes: 10, answers: 1
     Read on SO: [27] http://goo.gl/Q8MF9

   * What is the point of having a lazy/strict version of Writer?
     votes: 10, answers: 1
     Read on SO: [28] http://goo.gl/InUsm

   * Why can applicative functors have side effects, but functors can't?
     votes: 9, answers: 4
     Read on SO: [29] http://goo.gl/LxUi5

   * How to write fixed point build rules in Shake, e.g. Latex
     votes: 9, answers: 1
     Read on SO: [30] http://goo.gl/Ef82G

   * Event handling in Netwire compared to conventional FRP frameworks
     votes: 9, answers: 2
     Read on SO: [31] http://goo.gl/mA4Kc

Until next time,
Daniel Santa Cruz

References


_______________________________________________
Haskell mailing list
Haskell <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell
Jacob Thomas | 7 Feb 03:37 2013

Either example


Hello 

I'm new to Haskell, and need help with figuring out the Either type...
Any example to show how this works?

Jacob

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Alvaro Gutierrez | 7 Feb 05:04 2013
Picon

Re: Either example

Often, Either is used to represent, exclusively, a value or a failure, in a more detailed way than Maybe can. For example, a function like `parse` (http://hackage.haskell.org/packages/archive/parsec/latest/doc/html/Text-Parsec-Prim.html#v:parse), which is part of Parsec, might have a type like:

parse :: [...] s -> Either ParseError a

Meaning, parsing will either fail with a Left ParseError, or succeed with a Right a, where a is whatever type your parser returns.

Hope that helps,

Alvaro





On Wed, Feb 6, 2013 at 9:37 PM, Jacob Thomas <jthomas7 <at> ucsc.edu> wrote:

Hello 

I'm new to Haskell, and need help with figuring out the Either type...
Any example to show how this works?

Jacob


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Joachim Breitner | 7 Feb 09:36 2013
Picon

Re: GHCi (7.4.2) is working on ARM

Hi,

that’s no surprise:
“ARM support in the RTS linker (#5839) has been implemented.”
(http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/release-7-4-2.html)

Greetings,
Joachim

Am Mittwoch, den 06.02.2013, 18:21 -0500 schrieb dude:
> I have also validated ghc 7.4.1 on the Ubuntu Precise distro booted on
> a BeagleXM.
> 
> There's no ghci included.
> 
> --dude
> 
> On 02/06/2013 08:15 AM, kenny lu wrote:
> 
> > I've got a Cubieboard a few weeks back. I started it off with Linaro
> > (Ubuntu) 12.06.  
> > Today I started to upgrade the OS to 12.11, which surprisingly came
> > with ghc 7.4.2.
> > 
> > 
> > And ghci magically works too.
> > 
> > 
> > Here are the links
> > 
> > 
> > http://www.cubieboard.org
> > 
> > 
> > sudo apt-get install update-manager-core
> > sudo apt-get update
> > sudo apt-get upgrade
> > sudo do-release-upgrade
> > 
> > 
> > Regards,
> > Kenny
> > 
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe <at> haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
> -- 
> dude
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

--

-- 
Joachim "nomeata" Breitner
Debian Developer
  nomeata <at> debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nomeata <at> joachim-breitner.de | http://people.debian.org/~nomeata

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Doaitse Swierstra | 7 Feb 13:58 2013
Picon

Sol vingt simple problem in various languages and systems

At 

https://gist.github.com/ckirkendall/2934374 

you find solutions in many languages to a simple programming problem: the evaluation of an expression in an environment.

I want to point your attention to the currently last three entries:

  - one using the UUAGC compiler to solve the problem in an aspect oriented way (entered by Jeroen Bransen (jbransen))
  - one using some Haskell features, libraries and extensions (entered by me (doaitse))
  - one using our attribute grammar combinators from the AspectAG package, which expresses the 
    various aspects in an attribute grammar style (entered by Marcos Viera (marcosomarviera))

In case you did not manage to avoid getting wound up in a discussion about programming languages you can find
ammunition here.

 Doaitse
Ross Paterson | 7 Feb 15:08 2013
Picon

arrow notation

I'd like to hear from anyone who's using arrow notation as supported by GHC,
because I'm planning a couple of changes to parts of it.
Harald Bögeholz | 7 Feb 18:33 2013
Picon

Re: Either example

Am 07.02.13 03:37, schrieb Jacob Thomas:
> Hello
> 
> I'm new to Haskell, and need help with figuring out the Either type...
> Any example to show how this works?

Maybe a program I wrote a while ago can help you get it.

https://github.com/ctbo/slitherlink

In Slitherlink.hs there is a function readProblem that can fail. It
returns either a String with an error message (Left) or the problem read
(Right).

[...]
readProblem :: String -> Either String Problem
readProblem s = do
            pl <- readProblemList s
            when (null pl) $ Left "Problem is empty."
            let columns = length $ head pl
            when (columns == 0) $ Left "Problem starts with an empty line."
            unless (all ((== columns) . length) pl) $ Left "Problem not
rectangular."
            let rows = length pl
            return $ listArray ((0, 0), (rows-1, columns-1)) $ concat pl
[...]

Or if you don't feel comfortable with using the Either monad, look at
the even simpler function readConstraint a few lines earlier in the same
file.

In the main solve.hs program this is used to output a meaningful error
message to the user if the input file is invalid:

[...]
  where work s n = case readProblem s of
             Left e -> putStrLn e
             Right p -> do
[...do something with the problem p...]

Hope this helps.

Harald

--

-- 
Harald Bögeholz    <bo <at> ct.de> (PGP key available from servers)
Redaktion c't      Tel.: +49 511 5352-300  Fax: +49 511 5352-417
                   http://www.ct.de/

                   int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
                   main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
                   while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}
                                                          (Arndt/Haenel)

                   Affe Apfel Vergaser

/* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 *
   30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 *
   Persönlich haftende Gesellschafterin: Heise Zeitschriften Verlag *
   Geschäftsführung GmbH * Registergericht: Amtsgericht Hannover, HRB
   60405 * Geschäftsführer: Ansgar Heise, Dr. Alfons Schräder */
mukesh tiwari | 7 Feb 19:05 2013
Picon

Re: Either example

Hi Jocob
I would recommend you to go through the LYH ( http://learnyouahaskell.com/making-our-own-types-and-typeclasses ) .
data Either a b = Left a | Right b deriving (EqOrdReadShow

Lets say you have a division function and you want to avoid division by zero so this simple function
simpleDiv :: Int -> Int -> Int
simpleDiv m n = div m n

will through error and stop executing rest of you code ( See more on error handling ) so you can write your function which can handle this
 
division :: Int -> Int -> Either String Int
division m n
   | n == 0 = Left "Division by zero"
   | otherwise = Right  $ div m n

You can extend this solution as you wish and lets say you want both , some times integer division and some times floating point division based on flag. You set you flag true for floating division and false for integer division.

data Either' a b c = Left a | Mid b | Right c  deriving ( Show , Eq )

tempFunction :: Int -> Int -> Bool -> EIther' String Double Int
tempFunction m n f
   | n == 0 = Left "Division by zero"
   | f = Mid $ m / n  
   | otherwise = Right $ div m n

    
I haven't tested this code but the idea is if you want to return different  results then you use this. Also see Use of Either ( http://book.realworldhaskell.org/read/error-handling.html  ). Hopefully I have explained it correctly.

--Mukesh

On Thu, Feb 7, 2013 at 8:07 AM, Jacob Thomas <jthomas7 <at> ucsc.edu> wrote:

Hello 

I'm new to Haskell, and need help with figuring out the Either type...
Any example to show how this works?

Jacob


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Phil Freeman | 7 Feb 21:45 2013
Picon

Announce: LA Haskell User Group February Meeting

Dear Haskellers,
 
There will be a meeting of the LA Haskell User Group on Wednesday February 13th at 7pm. The details, including a list of discussion topics, as they become available, can be found here: http://www.meetup.com/Los-Angeles-Haskell-User-Group/events/102199892/
 
Thanks,
 
Phil Freeman.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Conal Elliott | 7 Feb 23:49 2013
Picon

Re: arrow notation

Hi Ross,

I make some use of arrow notation, though sadly I often have to avoid it because my (pseudo-)"arrows" don't have arr. I'd love to see a variant that has restricted expressiveness in exchange for arr-freeness.

-- Conal


On Thu, Feb 7, 2013 at 6:08 AM, Ross Paterson <ross <at> soi.city.ac.uk> wrote:
I'd like to hear from anyone who's using arrow notation as supported by GHC,
because I'm planning a couple of changes to parts of it.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane