[GHC] #6135: Unboxed Booleans

2012-05-31 Thread GHC
#6135: Unboxed Booleans
--+-
 Reporter:  benl  |  Owner:  
 Type:  feature request   | Status:  new 
 Priority:  normal|  Component:  Compiler
  Version:  7.4.1 |   Keywords:  
   Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown  |   Testcase:  
Blockedby:|   Blocking:  
  Related:|  
--+-
 Right now the only way to compare two integers is with primops that
 produce boxed bools:

 {{{
 #  :: Int# - Int# - Bool
 ==# :: Int# - Int# - Bool
 }}}

 To consume the resulting {{{Bool}}} we need a case-expression, which
 introduces branches into the core IR and object code. Case expressions are
 bad in the presence of heavy inlining because case-of-case performed by
 the GHC simplifier tends to duplicate code (like in DPH and Repa
 programs). Mis-predicted branches are bad in object code because they
 stall the pipeline.


 Consider the following expression:
 {{{
  case  x # 0# || x =# aWidth
 || y # 0# || y =# aHeight of
   True  - ...
   False - ...
 }}}

 This is very common in array programming. Ideally, it should turn into
 some straight-line code to compute the flag, and then a single branch
 instruction once we've worked out what alternative to take. However, as
 the only way to consume the {{{Bool}}}s produced by the comparisons is to
 introduce more case expressions, we end up with *four* cases in the core
 IR.

 What I want is this:
 {{{
 data Bool#
 (.#)  :: Int#  - Int#  - Bool#
 (.==#) :: Int#  - Int#  - Bool#
 (.||#) :: Bool# - Bool# - Bool#

 casex .# 0# .||# x .=# aWidth
.||# y .# 0# .||# y .=# aHeight of
  True#  - ...
  False# - ...
 }}}

 Bool# is the type of one bit integers. I can compute with them
 algebraically and be sure that I'll get at most one branch instruction in
 the resulting object code.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/6135
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #6136: gettimeofday should not be used to schedule timeouts

2012-05-31 Thread GHC
#6136: gettimeofday should not be used to schedule timeouts
--+-
 Reporter:  DanielWaterworth  |  Owner:  
 Type:  bug   | Status:  new 
 Priority:  normal|  Component:  libraries/base  
  Version:  7.4.1 |   Keywords:  
   Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown  |   Testcase:  
Blockedby:|   Blocking:  
  Related:|  
--+-
 From what I can tell,
 [http://hackage.haskell.org/packages/archive/base/latest/doc/html/src/GHC-
 Event-Clock.html#getCurrentTime getCurrentTime] uses gettimeofday and is
 used in
 [http://hackage.haskell.org/packages/archive/base/latest/doc/html/src/GHC-
 Event-Manager.html#registerTimeout registerTimeout] for the purpose of
 scheduling timeouts. I recommend reading [http://blog.habets.pp.se/2010/09
 /gettimeofday-should-never-be-used-to-measure-time this] for an
 explanation of why this isn't a good idea.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/6136
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #6136: gettimeofday should not be used to schedule timeouts

2012-05-31 Thread GHC
#6136: gettimeofday should not be used to schedule timeouts
---+
  Reporter:  DanielWaterworth  |  Owner:  
  Type:  bug   | Status:  closed  
  Priority:  normal|  Milestone:  7.6.1   
 Component:  libraries/base|Version:  7.4.1   
Resolution:  duplicate |   Keywords:  
Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  | Difficulty:  Unknown 
  Testcase:|  Blockedby:  
  Blocking:|Related:  #5865   
---+
Changes (by pcapriotti):

  * status:  new = closed
  * difficulty:  = Unknown
  * resolution:  = duplicate
  * related:  = #5865
  * milestone:  = 7.6.1


Comment:

 Thanks for the report.

 We already switched to monotonic timers in HEAD. See #5865.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/6136#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #6136: gettimeofday should not be used to schedule timeouts

2012-05-31 Thread GHC
#6136: gettimeofday should not be used to schedule timeouts
---+
  Reporter:  DanielWaterworth  |  Owner:  
  Type:  bug   | Status:  closed  
  Priority:  normal|  Milestone:  7.6.1   
 Component:  libraries/base|Version:  7.4.1   
Resolution:  duplicate |   Keywords:  
Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  | Difficulty:  Unknown 
  Testcase:|  Blockedby:  
  Blocking:|Related:  #5865   
---+

Comment(by DanielWaterworth):

 Thanks!

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/6136#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5936: Support for data families in generics

2012-05-31 Thread GHC
#5936: Support for data families in generics
-+--
Reporter:  reinerp   |   Owner:  dreixel 
Type:  feature request   |  Status:  patch   
Priority:  normal|   Milestone:  
   Component:  Compiler  | Version:  7.4.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by bgamari):

 * cc: bgamari@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5936#comment:5
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5936: Support for data families in generics

2012-05-31 Thread GHC
#5936: Support for data families in generics
-+--
Reporter:  reinerp   |   Owner:  dreixel 
Type:  feature request   |  Status:  patch   
Priority:  normal|   Milestone:  
   Component:  Compiler  | Version:  7.4.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--

Comment(by bgamari):

 Any thoughts on how to move forward on this?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5936#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5936: Support for data families in generics

2012-05-31 Thread GHC
#5936: Support for data families in generics
-+--
Reporter:  reinerp   |   Owner:  dreixel 
Type:  feature request   |  Status:  patch   
Priority:  normal|   Milestone:  
   Component:  Compiler  | Version:  7.4.1   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--

Comment(by dreixel):

 Replying to [comment:6 bgamari]:
  Any thoughts on how to move forward on this?

 I don't think it'll be too hard; I've just been very busy with deadlines.
 Hope to have a look at it next week.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5936#comment:7
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [Haskell] (no subject)

2012-05-31 Thread Alexander Kantardjiev

wow look into this http://www.stenews.net/biz/?read=3610300


___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell-cafe] Fundeps and overlapping instances

2012-05-31 Thread Etienne Laurin
2012/5/31 Iavor Diatchki iavor.diatc...@gmail.com:
 Hello,

 the notion of a functional dependency is well established, and it was used
 well before it was introduced to Haskell (for example, take a look
 at http://en.wikipedia.org/wiki/Functional_dependency).  So I'd be weary to
 redefine it lightly.

Indeed, GHC's functional dependencies are not the same. I see you have
already talked about this on the GHC bug tracker.

http://hackage.haskell.org/trac/ghc/ticket/1241

 1. Check that an instance is consistent with itself.  For example, this 
 should be rejected:

 instance C a b

 because it allows C Int Bool and C Int Char which violate the functional 
 dependency.

This check may not always be as straightforward. When would this be a
valid instance?

instance K a b ⇒ C a b

With a few extra extensions, K could be a type family.

C currently has the kind (a - b - Constraint), with no mention of
functional dependencies. Perhaps the kind of C should include the
functional dependencies of C?

Etienne Laurin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Troubles understanding Parsec Error Handling

2012-05-31 Thread Matthias Hörmann
Hello

Thanks for the quick help with this. I thought about the idea that
lookAhead might be the cause of the
positioning bug but then discarded that idea because I thought lookAhead
should never lead to an error
past wherever the input position is now considering it doesn't consume any
input.

I am aware of the issue with the error message position and the output, I
was still working on improving
that when I was puzzled by the fact that the error message I specified
wasn't even returned to me.

As for try, I believe I need it to make sure the input I consume one
character at the time, before I know
if I will reach another valid match (or any at all) does not stay consumed
when my parser fails.

I am still very much in the experimental phase as far as writing Parsec
combinators beyond very simple
stuff is concerned so I am open for suggestions on how to improve it in a
way that doesn't need try.

Thanks again for all the help and especially for the patch. After applying
it I do get the error message I
specified.

I noticed there are still some other problems in the code. In particular it
doesn't work as intended in cases
like this one:

parseTest (do; r1 - anyOf [Hello, Hallo, Foo, HallofFame]; r2 -
string fbla; return (r1, r2)) Hallofbla

where it should (according to my goal) return no parse error but instead
accept Hallo and allow the string parser
to consume the rejected suffix but I will try to fix that.

Matthias Hoermann
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Requesting Feedback: I Love Haskell, but can't find a place to use it

2012-05-31 Thread Johannes Waldmann
Jonathan Geddes geddes.jonathan at gmail.com writes:

 I love Haskell. It is my absolute favorite language. 
 But I have a very hard time finding places where I can actually use it!

have you considered your head as such a place that should be easy to find.

even just for specifying things, Haskell is tremendously useful.
even if you don't write programs, but just their types.
you can express your software design that way,
and have it formally verified (by the compiler's type checker).

best regards, J. W.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Requesting Feedback: I Love Haskell, but can't find a place to use it

2012-05-31 Thread Ivan Perez
On 31 May 2012 01:30, Jonathan Geddes geddes.jonat...@gmail.com wrote:
 I love Haskell. It is my absolute favorite language. But I have a very hard
 time finding places where I can actually use it!
This has been bugging me for years and, like you, I think we ought to
lean towards web-pages and mobile devices.

Yesod has been a tremendous push forward in this direction but, as you
already stated, the browser and android devices remain mostly
unexplored in Haskell. Here's my bit:

- There's a port of ghc for iphone.
- There's frege (http://code.google.com/p/frege/), a non-strict, pure,
functional programming language in the spirit of Haskell.
- I've been working as a freelance developer for some time now. I
focus on desktop apps in Haskell. I can't say I'm overwhelmed by the
amount of offers (speaking of which, if anyone needs a freelance
haskell developer,... ahem), but this area will not be clinically
dead as long as we cannot use web applications knowing (99% sure)
that the owner of the website cannot use our personal information for
any purpose other than giving us our service. There's only two kinds
of clients here, though: those that explicitly want Haskell, and those
than don't care about the programming language. Otherwise, you'll have
to sell Haskell and, personally, I'm not that good a salesman (10%
success, tops).
- I've also ported Haskell designs to other programming languages
(with small adaptations). I only found this cost-effective because the
code in Haskell was not going to be thrown away.

Good luck. Please, let us know what you find.

Cheers,
Ivan.

 I had hoped that compiling Haskell to C with -fvia-C (or would it be just
 -C?) would allow Haskell to run in new, uncharted territory such as Android
 (with NDK), IOS, Google's NaCl, etc. But today I learned that GHC's C
 backend has been deprecated!  Is it more difficult than I am imagining to
 get Haskell to work in these environments? Is it simply a matter of low
 interest in this kind of work? Or something more fundamental? Am I missing
 something?

 I'm hoping that the Haskell-JavaScript efforts will mature enough to make
 Haskell viable for client-side web apps. (I think the first sign of this
 will be a self-hosting Haskell-JavaScript compiler.)

 I use Haskell for Server-Side code with various web frameworks, but over the
 years more and more of the app logic is moved into client-side JavaScript,
 leaving the server-side code as little more than a simple validation and
 security layer over the database and other services. Haskell doesn't have
 any trouble with this, of course, but it's not exactly a role where it can
 shine. (Of course this is not true of ALL server-side code, just the kind of
 apps I have been writing.)

 So anyway I'd like to request feedback: where can I use Haskell besides
 simple CLI utilities, dull server code, or project Euler problems? Even if
 it's just to contribute to getting Haskell in the environments mentioned
 above, any feedback is welcome!

 Thanks for reading,

 --J Arthur

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Requesting Feedback: I Love Haskell, but can't find a place to use it

2012-05-31 Thread Jonathan Geddes
Thanks for the responses, everyone.

J. W. wrote:
have you considered your head as such a place that should be easy to
find.
 even just for specifying things, Haskell is tremendously useful.
even if you don't write programs, but just their types.
you can express your software design that way,
 and have it formally verified (by the compiler's type checker).

Yes! And in fact this is exactly how I use Haskell now (aside from little
scripts and such). It has had a HUGE effect on the way I write software.
There have been a number of times that a colleague has asked what a strange
comment was in my Java[Script] code. When I tell them that the funny
looking one-liner is the Haskell equivalent of the following 30+
Java[Script] lines, they are incredulous, to say the least. But taking that
beautiful Haskell one-liner and manually transcribing it into an imperative
language feels like being a human compiler. My favorite example of this was
the use of the power set in JavaScript:

//powerSet = filterM (const [True, False])

and then a few dozen JavaScript lines it compiled down to via the human
compiler.

--J Arthur


On Thu, May 31, 2012 at 8:41 AM, Ivan Perez ivanperezdoming...@gmail.comwrote:

 On 31 May 2012 01:30, Jonathan Geddes geddes.jonat...@gmail.com wrote:
  I love Haskell. It is my absolute favorite language. But I have a very
 hard
  time finding places where I can actually use it!
 This has been bugging me for years and, like you, I think we ought to
 lean towards web-pages and mobile devices.

 Yesod has been a tremendous push forward in this direction but, as you
 already stated, the browser and android devices remain mostly
 unexplored in Haskell. Here's my bit:

 - There's a port of ghc for iphone.
 - There's frege (http://code.google.com/p/frege/), a non-strict, pure,
 functional programming language in the spirit of Haskell.
 - I've been working as a freelance developer for some time now. I
 focus on desktop apps in Haskell. I can't say I'm overwhelmed by the
 amount of offers (speaking of which, if anyone needs a freelance
 haskell developer,... ahem), but this area will not be clinically
 dead as long as we cannot use web applications knowing (99% sure)
 that the owner of the website cannot use our personal information for
 any purpose other than giving us our service. There's only two kinds
 of clients here, though: those that explicitly want Haskell, and those
 than don't care about the programming language. Otherwise, you'll have
 to sell Haskell and, personally, I'm not that good a salesman (10%
 success, tops).
 - I've also ported Haskell designs to other programming languages
 (with small adaptations). I only found this cost-effective because the
 code in Haskell was not going to be thrown away.

 Good luck. Please, let us know what you find.

 Cheers,
 Ivan.

  I had hoped that compiling Haskell to C with -fvia-C (or would it be just
  -C?) would allow Haskell to run in new, uncharted territory such as
 Android
  (with NDK), IOS, Google's NaCl, etc. But today I learned that GHC's C
  backend has been deprecated!  Is it more difficult than I am imagining to
  get Haskell to work in these environments? Is it simply a matter of low
  interest in this kind of work? Or something more fundamental? Am I
 missing
  something?
 
  I'm hoping that the Haskell-JavaScript efforts will mature enough to
 make
  Haskell viable for client-side web apps. (I think the first sign of this
  will be a self-hosting Haskell-JavaScript compiler.)
 
  I use Haskell for Server-Side code with various web frameworks, but over
 the
  years more and more of the app logic is moved into client-side
 JavaScript,
  leaving the server-side code as little more than a simple validation and
  security layer over the database and other services. Haskell doesn't have
  any trouble with this, of course, but it's not exactly a role where it
 can
  shine. (Of course this is not true of ALL server-side code, just the
 kind of
  apps I have been writing.)
 
  So anyway I'd like to request feedback: where can I use Haskell besides
  simple CLI utilities, dull server code, or project Euler problems? Even
 if
  it's just to contribute to getting Haskell in the environments mentioned
  above, any feedback is welcome!
 
  Thanks for reading,
 
  --J Arthur
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Confused by ghci output

2012-05-31 Thread Clark Gaebel
*X 3^40 `mod` 3 == modexp2 3 40 3
False
*X modexp2 3 40 3
0
*X 3^40 `mod` 3
0

I'm confused. Last I checked, 0 == 0.

Using GHC 7.4.1, and the file x.hs (which has been loaded in ghci) can be
found here: http://hpaste.org/69342

I noticed this after prop_sanemodexp was failing.

Any help would be appreciated,
  - Clark
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Claude Heiland-Allen

Hi Clark,

ghci is defaulting to Integer
modexp2 forces Int
Int overflows with 3^40

On 31/05/12 17:35, Clark Gaebel wrote:

*X  3^40 `mod` 3 == modexp2 3 40 3
False


*X fromInteger (3^40 `mod` 3) == modexp2 3 40 3
True


*X  modexp2 3 40 3
0
*X  3^40 `mod` 3
0


*X 3^40 `mod` 3 ::Int
2


I'm confused. Last I checked, 0 == 0.


Int overflow is ugly!

*X 3^40
12157665459056928801
*X maxBound :: Int
9223372036854775807


Claude



Using GHC 7.4.1, and the file x.hs (which has been loaded in ghci) can be
found here: http://hpaste.org/69342

I noticed this after prop_sanemodexp was failing.

Any help would be appreciated,
   - Clark




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Ertugrul Söylemez
Clark Gaebel cgae...@uwaterloo.ca wrote:

 *X 3^40 `mod` 3 == modexp2 3 40 3
 False
 *X modexp2 3 40 3
 0
 *X 3^40 `mod` 3
 0

 I'm confused. Last I checked, 0 == 0.

This has to do with types:

 3^40 `mod` 3
0

 3^40 `mod` 3 :: Int
2

When doing number theory always use Integer.


Greets,
Ertugrul

-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://ertes.de/


signature.asc
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Kevin Charter
Hi Clark,

On Thu, May 31, 2012 at 10:35 AM, Clark Gaebel cgae...@uwaterloo.ca wrote:

 *X 3^40 `mod` 3 == modexp2 3 40 3
 False
 *X modexp2 3 40 3
 0
 *X 3^40 `mod` 3
 0

 I'm confused. Last I checked, 0 == 0.


Your HPaste shows the type of modexp2 is Int - Int - Int - Int, so ghci
will infer that (3^40) is an Int. But an Int isn't big enough to hold 3^40.

Prelude 3^40 :: Int
-6289078614652622815
Prelude (3^40 :: Int) `mod` 3
2

Kevin
-- 
Kevin Charter
kevin.char...@acm.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Clark Gaebel
Wow, thanks! That was subtle.

  - Clark

On Thu, May 31, 2012 at 12:49 PM, Claude Heiland-Allen cla...@goto10.orgwrote:

 Hi Clark,

 ghci is defaulting to Integer
 modexp2 forces Int
 Int overflows with 3^40


 On 31/05/12 17:35, Clark Gaebel wrote:

 *X  3^40 `mod` 3 == modexp2 3 40 3
 False


 *X fromInteger (3^40 `mod` 3) == modexp2 3 40 3
 True


  *X  modexp2 3 40 3
 0
 *X  3^40 `mod` 3
 0


 *X 3^40 `mod` 3 ::Int

 2

  I'm confused. Last I checked, 0 == 0.


 Int overflow is ugly!

 *X 3^40
 12157665459056928801
 *X maxBound :: Int
 9223372036854775807


 Claude


 Using GHC 7.4.1, and the file x.hs (which has been loaded in ghci) can be
 found here: http://hpaste.org/69342

 I noticed this after prop_sanemodexp was failing.

 Any help would be appreciated,
   - Clark




 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe



 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Simon Hengel
ghci 3^40 `mod` 3 :: Int
2

Cheers,
Simon

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Sean Leather
On Thu, May 31, 2012 at 6:35 PM, Clark Gaebel wrote:

 *X 3^40 `mod` 3 == modexp2 3 40 3
 False
 *X modexp2 3 40 3
 0
 *X 3^40 `mod` 3
 0


*X 3^40 `mod` 3 :: Int
1
*X 3^40 `mod` 3 :: Integer
0

I'm confused. Last I checked, 0 == 0.


Yes, but 3^40 /= 3^40 when you have arithmetic overflow:

*X 3^40 :: Int
689956897
*X 3^40 :: Integer
12157665459056928801

Regards,
Sean
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Lorenzo Bolla
It looks like you are overflowing `Int` with 3^40.
In your QuickCheck test, the function signature uses Int:

prop_sanemodexp :: Int - Int - Int - Property

Note:
Prelude 3^40
12157665459056928801
Prelude 3^40 :: Int
689956897

Prelude 3^40 `mod` 3
0
Prelude (3^40 `mod` 3) :: Int
1


L.




On Thu, May 31, 2012 at 5:35 PM, Clark Gaebel cgae...@uwaterloo.ca wrote:

 *X 3^40 `mod` 3 == modexp2 3 40 3
 False
 *X modexp2 3 40 3
 0
 *X 3^40 `mod` 3
 0

 I'm confused. Last I checked, 0 == 0.

 Using GHC 7.4.1, and the file x.hs (which has been loaded in ghci) can be
 found here: http://hpaste.org/69342

 I noticed this after prop_sanemodexp was failing.

 Any help would be appreciated,
   - Clark
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread Clark Gaebel
The cafe is certainly responsive today!

Thanks everyone - got it. Integer overflow ;)

Regards,
  - Clark
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Requesting Feedback: I Love Haskell, but can't find a place to use it

2012-05-31 Thread Vagif Verdi
Besides our web app and batch pdf generation procedures, i use haskell for 
internal one-off tasks.
Often i am being asked to import various data to database from text/excel 
files. Haskell is an excellent tool for this.


On Wednesday, May 30, 2012 5:30:28 PM UTC-7, Jonathan Geddes wrote:

 I love Haskell. It is my absolute favorite language. But I have a very 
 hard time finding places where I can actually use it!

 I had hoped that compiling Haskell to C with -fvia-C (or would it be just 
 -C?) would allow Haskell to run in new, uncharted territory such as Android 
 (with NDK), IOS, Google's NaCl, etc. But today I learned that GHC's C 
 backend has been deprecated!  Is it more difficult than I am imagining to 
 get Haskell to work in these environments? Is it simply a matter of low 
 interest in this kind of work? Or something more fundamental? Am I missing 
 something?

 I'm hoping that the Haskell-JavaScript efforts will mature enough to make 
 Haskell viable for client-side web apps. (I think the first sign of this 
 will be a self-hosting Haskell-JavaScript compiler.)

 I use Haskell for Server-Side code with various web frameworks, but over 
 the years more and more of the app logic is moved into client-side 
 JavaScript, leaving the server-side code as little more than a simple 
 validation and security layer over the database and other services. Haskell 
 doesn't have any trouble with this, of course, but it's not exactly a role 
 where it can shine. (Of course this is not true of ALL server-side code, 
 just the kind of apps I have been writing.)

 So anyway I'd like to request feedback: where can I use Haskell besides 
 simple CLI utilities, dull server code, or project Euler problems? Even if 
 it's just to contribute to getting Haskell in the environments mentioned 
 above, any feedback is welcome!

 Thanks for reading,

 --J Arthur

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Need inputs for a Haskell awareness presentation

2012-05-31 Thread C K Kashyap
Hi folks,

I have the opportunity to make a presentation to folks (developers and
managers) in my organization about Haskell - and why it's important - and
why it's the only way forward. I request you to share your
experiences/suggestions for the following -
1. Any thoughts around the outline of the presentation - target audience
being seasoned imperative programmers who love and live at the pinnacle of
 object oriented bliss.
2. Handling questions/comments like these in witty/interesting ways -
a) It looks good and mathematical but practically, what can we do with
it, all our stuff is in C++
b) Wow, what do you mean you cannot reason about its space complexity?
c) Where's my inheritance?
d) Debugging looks like a nightmare - we cannot even put a print in the
function?
e) Static types - in this day and age - come on - productivity in X is
so much more - and that's because they got rid of type mess.
f)  Is there anything serious/large written in it? [GHC will not
qualify as a good answer I feel]
g) Oh FP, as in Lisp, oh, that's AI stuff right ... we don't really do
AI.
h) Any other questions/comments that you may have heard.
3. Ideas about interesting problems that can be used so that it appeals to
people. I mean, while fibonacci etc look good but showing those examples
tend to send the signal that it's good for those kind of problems.
4. Is talking about or referring to Lambda calculus a good idea - I mean,
showing that using its ultra simple constructs one could build up things
like if/then etc

I'm gonna do my bit to wear the limestone!!!

Regards,
Kashyap
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need inputs for a Haskell awareness presentation

2012-05-31 Thread Clark Gaebel
Regarding 2d, Debug.Trace is perfect for that.

On Thu, May 31, 2012 at 2:23 PM, C K Kashyap ckkash...@gmail.com wrote:

 Hi folks,

 I have the opportunity to make a presentation to folks (developers and
 managers) in my organization about Haskell - and why it's important - and
 why it's the only way forward. I request you to share your
 experiences/suggestions for the following -
 1. Any thoughts around the outline of the presentation - target audience
 being seasoned imperative programmers who love and live at the pinnacle of
  object oriented bliss.
 2. Handling questions/comments like these in witty/interesting ways -
 a) It looks good and mathematical but practically, what can we do with
 it, all our stuff is in C++
 b) Wow, what do you mean you cannot reason about its space complexity?
 c) Where's my inheritance?
 d) Debugging looks like a nightmare - we cannot even put a print in
 the function?
 e) Static types - in this day and age - come on - productivity in X is
 so much more - and that's because they got rid of type mess.
 f)  Is there anything serious/large written in it? [GHC will not
 qualify as a good answer I feel]
 g) Oh FP, as in Lisp, oh, that's AI stuff right ... we don't really do
 AI.
 h) Any other questions/comments that you may have heard.
 3. Ideas about interesting problems that can be used so that it appeals to
 people. I mean, while fibonacci etc look good but showing those examples
 tend to send the signal that it's good for those kind of problems.
 4. Is talking about or referring to Lambda calculus a good idea - I mean,
 showing that using its ultra simple constructs one could build up things
 like if/then etc

 I'm gonna do my bit to wear the limestone!!!

 Regards,
 Kashyap

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need inputs for a Haskell awareness presentation

2012-05-31 Thread Rustom Mody
On Thu, May 31, 2012 at 11:53 PM, C K Kashyap ckkash...@gmail.com wrote:

 Hi folks,

 I have the opportunity to make a presentation to folks (developers and
 managers) in my organization about Haskell - and why it's important - and
 why it's the only way forward.


You (and we) may believe that but saying so usually does not work.
What is more likely to work is talking to people about what interests them
(rather than you :-) ).  For example teachers of CS are usually struck by
and bowled over by quicksort in 2 lines because for them teaching quicksort
is considered an important activity.  Professional object-oriented
programmers are unlikely to take to such an 'academic' example kindly.
Likewise those interested in algorithms and data-structures would be caught
by a (tree) dfs in 1 line, or that a graph dfs and bfs are the same except
that a
[x] ++ pending
becomes
pending ++ [x]
But if they were not so interested in algos and data-structures (Java
programmers more than C++ are particularly prone to being using-happy,
understanding-chary) this example would not work.

So in short find what matters to your audience and then survey, focus and
drill into that -- using Haskell


 I request you to share your experiences/suggestions for the following -
 1. Any thoughts around the outline of the presentation - target audience
 being seasoned imperative programmers who love and live at the pinnacle of
  object oriented bliss.
 2. Handling questions/comments like these in witty/interesting ways -
 a) It looks good and mathematical but practically, what can we do with
 it, all our stuff is in C++
 b) Wow, what do you mean you cannot reason about its space complexity?
 c) Where's my inheritance?


Yes you need to find a hot OO guru saying that inheritance is best avoided
where templates/STL etc work

d) Debugging looks like a nightmare - we cannot even put a print in the
 function?


Maybe a (concocted) example of how the typechecker does most of the
debugging for you? Better of course if the example is genuinely hacked out
in front of the class (ideally from some thing they want to see solved)
that can be convincing re things like debugging.

This also brings up what is (for me) a very important point regarding
haskell -- using an interpreter, ie ghci.
-- the tight feedback loop
-- not being bound to having to write a main
-- the general sense of a workbench in which various objects (some joke
here for the OO guys?) are are in different states of under construction to
shrink-wrapped

Personally I do not see how I could teach (or do) haskell without emacs.
Admittedly this attracts some strongly and repels others equally strongly

e) Static types - in this day and age - come on - productivity in X is
 so much more - and that's because they got rid of type mess.
 f)  Is there anything serious/large written in it? [GHC will not
 qualify as a good answer I feel]
 g) Oh FP, as in Lisp, oh, that's AI stuff right ... we don't really do
 AI.
 h) Any other questions/comments that you may have heard.
 3. Ideas about interesting problems that can be used so that it appeals to
 people. I mean, while fibonacci etc look good but showing those examples
 tend to send the signal that it's good for those kind of problems.
 4. Is talking about or referring to Lambda calculus a good idea - I mean,
 showing that using its ultra simple constructs one could build up things
 like if/then etc

 I'm gonna do my bit to wear the limestone!!!

 Regards,
 Kashyap

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need inputs for a Haskell awareness presentation

2012-05-31 Thread Anton Kholomiov
a) you can generate c++ with it :) (but don't tell it.
it may be regarded as offense)

b) -

c) -

d) stop debugging, you don't need it that much in
haskell. But you need profiler. If they really want
to print something in pure function you can show
them function 'trace', from Debug.Trace

e) I don't think that C++ people think that types are bad.
If they do you can tell (beside the types don't let you
mess up to much and stimulate clarity and documentation)
about how easy is to do refactoring in typed language.

f) You can show them Atom [1]. 5k Haskell code generates
20k C-code and it all works in real time in real trucks.
Or Copilot. It's going to be used in airplanes.

4. I think it's bad idea. It's better to start with
examples.

What really strikes me about haskell is the simplicity of
data types. I think the best way to start is to show
Booleans, then lists, then Trees. It's so simple and
beautiful

You can say. Do you really need to know anything
about syntax to understand this:

data Bool = False | True

or this

data Time = Time Hour Minute Second

or this

data List a = Nil | Cons a (List a)

and you can say that it is not built in. You can define it
yourself and it works as fast as any other data type
(or as slow).

You can stress the idea of haskell data types is
haskell UML.

Don't show definitions just show them types like this:

not :: Bool - Bool
and :: Bool - Bool - Bool

reverse :: [a] - [a]
map :: (a - b) - [a] - [b]

then you can show definitions and say about pattern matching.
It is very intuitive.


[1] http://hackage.haskell.org/package/atom
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Troubles understanding Parsec Error Handling

2012-05-31 Thread Roman Cheplyaka
* Matthias Hörmann mhoerm...@gmail.com [2012-05-31 10:40:31+0200]
 I noticed there are still some other problems in the code. In particular it
 doesn't work as intended in cases
 like this one:
 
 parseTest (do; r1 - anyOf [Hello, Hallo, Foo, HallofFame]; r2 -
 string fbla; return (r1, r2)) Hallofbla
 
 where it should (according to my goal) return no parse error but instead
 accept Hallo and allow the string parser
 to consume the rejected suffix but I will try to fix that.

This looks more like a job for regular expressions.
E.g. using the regex-applicative package:

 let anyOf = foldr1 (|) . map string
 let re = (,) $ anyOf [Hello, Hallo, Foo, HallofFame] * string 
fbla
 Hallofbla =~ re

Just (Hallo,fbla)

Theoretically regular expressions also do the kind of optimization that
you achieve with a trie, but this particular engine doesn't. Nevertheless,
it may be a good base for your own engine.

-- 
Roman I. Cheplyaka :: http://ro-che.info/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Requesting Feedback: I Love Haskell, but can't find a place to use it

2012-05-31 Thread Richard O'Keefe
It's difficult to imagine any kind of program that doesn't need
testing; surely there is a role for Haskell in writing test data
generators?



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Most Important GHC extensions to learn/use?

2012-05-31 Thread Jonathan Geddes
Haskell Hackers,

I'm pretty comfortable with all of Haskell 98 (and 2010, really). But I've
always sort of avoided extensions. I realize that this is a bit silly and
if I want to continue learning, it probably means delving into the
extensions. Which ones are the most important to know from a practical
point of view? And which ones from a {Language,Category,Math}-theoretical
point of view? (Any other interesting/important points of view I'm missing?
:D )

As always, thanks for the feedback.

Cheers,

--J Arthur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need inputs for a Haskell awareness presentation

2012-05-31 Thread Chris Wong
On Fri, Jun 1, 2012 at 6:23 AM, C K Kashyap ckkash...@gmail.com wrote:
 Hi folks,

 I have the opportunity to make a presentation to folks (developers and
 managers) in my organization about Haskell - and why it's important - and
 why it's the only way forward. I request you to share your
 experiences/suggestions for the following -
 1. Any thoughts around the outline of the presentation - target audience
 being seasoned imperative programmers who love and live at the pinnacle of
  object oriented bliss.

Rustom nailed it. Take something imperative languages are really,
really bad at and *show* how it's done in Haskell.

*   Parsing

Haskell parser combinators make yacc look old school. By
leveraging Haskell's DSL features, parsers often end up looking like
the grammar they're implementing. Different parser combinator
libraries let you do incremental input  (Attoparsec), show clang-style
diagnostics (Trifecta), or perform crazy optimizations automatically
(uu-parsinglib).

*   Iteratee I/O

encodeFile from to = mapOutput encode (sourceFile from) $$ sinkFile to

It may not look like it, but the above function (using the
conduit package) sets up a I/O pipeline that uses constant memory.
There are HTTP, FTP, text encoding and parser libraries that can hook
into the pipeline the same way. All the resources (sockets, file
handles) tied up in the pipeline are finalized automatically when it
finishes or when an exception is thrown.

*   Epic concurrency

GHC comes with preemptive scheduling, STM and async I/O built in.
Maybe you could demonstrate these with a ping-pong-style application.

 2. Handling questions/comments like these in witty/interesting ways -
     a) It looks good and mathematical but practically, what can we do with
 it, all our stuff is in C++

Anything you can do in another Turing-complete language ;)

Quite a few folks have helped push Haskell into the practical world,
with useful things like web frameworks, ByteStrings, GUI bindings...
It's suitable for practical applications already.

     b) Wow, what do you mean you cannot reason about its space complexity?

That's not a bug, it's a feature!

C++ gives you lots of control over how your program runs.
Unfortunately, most people don't need that or don't know how to use it
effectively. So most of the time, these low-level features just add a
bunch of cruft with no real benefit to the programmer.

Haskell goes the opposite way. The Haskell standard goes out of its
way *not* to say how programs actually run -- only what the result
should be. This lets the compiler optimize much more than in other
languages.

This philosophy is reflected in a common technique called stream
fusion. I can't be bothered writing an example for this, but Google
it and you'll find a few.

     c) Where's my inheritance?

Right behind you ;)

     d) Debugging looks like a nightmare - we cannot even put a print in the
 function?

Traditional debugging -- stepping through the program line by line --
fails miserably in Haskell, mostly due to (b).

Haskell programmers tend to use more mathematical techniques:
* Property-based testing, e.g. reverse (reverse xs) == xs. Used
extensively in Xmonad.
* Algebraic proofs (this works especially well for framework stuff
like the MTL).
* Sexy types: encoding invariants in the type so the compiler checks
it for you. The fb (Facebook API) package does this with the NoAuth
and Auth phantom types.

For I/O-centric code, there's the traditional HUnit and HSpec.

And as Clark said, there's always Debug.Trace.

     e) Static types - in this day and age - come on - productivity in X is
 so much more - and that's because they got rid of type mess.

The designers of Haskell went out of their way to make sure 99% of
types can be inferred by the compiler. It's good practice to put type
annotations on things, but you don't have to.

     f)  Is there anything serious/large written in it? [GHC will not
 qualify as a good answer I feel]

* Yesod and Snap and Happstack -- all mature, well documented web
frameworks. Yesod is the check-everything-at-compile-time one, Snap is
the mix-and-match one and Happstack is the use-lots-of-combinators
one.
* Warp, a simple yet full-featured web server, trashes the competition
in terms of performance -- yet consists of less than 1k lines of code.
It uses all three of the techniques I mentioned above.
* Xmonad is a window manager. I've used quite a few tiling window
managers before, and Xmonad is the only one that hasn't crashed.
* Geordi (http://www.eelis.net/geordi/), an IRC bot that compiles and
runs C++ code, is written in Haskell.

     g) Oh FP, as in Lisp, oh, that's AI stuff right ... we don't really do
 AI.
     h) Any other questions/comments that you may have heard.
 3. Ideas about interesting problems that can be used so that it appeals to
 people. I mean, while fibonacci etc look good but showing those examples
 tend to send the signal that it's good for those kind of problems.
 

Re: [Haskell-cafe] Fundeps and overlapping instances

2012-05-31 Thread AntC
Iavor Diatchki iavor.diatchki at gmail.com writes:

 
 Hello,
 
 the notion of a functional dependency is well established, and it was used 
well before it was introduced to Haskell (for example, take a look 
at http://en.wikipedia.org/wiki/Functional_dependency).  So I'd be weary to 
redefine it lightly.

Yes functional dependency is well established in relational algebra (set 
theory actually) -- it's about values in attributes. But there's nothing 
corresponding to typevars (I suppose you might call those patterns of values); 
there's nothing like overlaps.

Perhaps instances with Fundeps should only use H98-style arguments? Perhaps we 
should disallow overlaps with Fundeps (as Hugs does pretty-much)?

I can only understand tricky Fundeps by mentally translating them into type-
level functions (and I was doing that before type families/associated types 
came along).

class C a b| a - b=== type family CF a
instance C a b === type instance CF a = b

And that type instance is rejected because `b' is not in scope.

Currently there are all sorts of tricks in instance declarations with overlaps 
and Fundeps, to achieve the effect of type-level functions. You do end up with 
instance arguments being all typevars, because the instance selection logic is 
really going on inside the constraints, with type-level 'helper functions'.

Some of Oleg's instances are awesome (and almost impenetrable -- the TTypeable 
code is a tour de force).

It's all so *dys-functional* (IMO).

My take is that we should abandon Fundeps, and concentrate on introducing 
overlaps into type functions in a controlled way (what I've called 'dis-
overlapped overlaps'.)

AntC



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Confused by ghci output

2012-05-31 Thread wren ng thornton

On 5/31/12 12:48 PM, Lorenzo Bolla wrote:

It looks like you are overflowing `Int` with 3^40.
In your QuickCheck test, the function signature uses Int:


+1.

I was bitten by this issue recently as well. When playing around with 
properties and debugging in GHCi, always beware of type defaulting to 
Integer.


--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Most Important GHC extensions to learn/use?

2012-05-31 Thread wren ng thornton

On 5/31/12 7:15 PM, Jonathan Geddes wrote:

Haskell Hackers,

I'm pretty comfortable with all of Haskell 98 (and 2010, really). But I've
always sort of avoided extensions. I realize that this is a bit silly and
if I want to continue learning, it probably means delving into the
extensions. Which ones are the most important to know from a practical
point of view? And which ones from a {Language,Category,Math}-theoretical
point of view? (Any other interesting/important points of view I'm missing?
:D )


There are a bunch which are mostly just syntax changes. The important 
ones are:


ForeignFunctionInterface (aka FFI)
Not technically part of H98, though it was a quick addition. It
is part of H2010, so it's not really an extension anymore.

ScopedTypeVariables
This one's really easy, and in the cases where you want it you
really really want it.

KindSignatures
This one's simple, and it helps expose you to the idea of
kinds, which is helpful for what's to come.

TypeOperators
This one's trivial, but it makes things a bit prettier.

FlexibleContexts, FlexibleInstances
These are essential for actually using MPTCs (described below).
IMO they should be enabled automatically whenever MPTCs are on.

And there are also a bunch of ones about extending the deriving 
mechanic to work with new classes or with newtypes.



Then there are the ones that actually change the language in a 
significant way. I'd say the critical ones to learn are:


RankNTypes (or Rank2Types if you're squeamish)
This is used in lots of nice tricks like list fusion. Learning
list fusion is a good place for the H98 veteran to explore
next, since it's easy to pick up and has many applications
outside of just doing list fusion. Also, it's been around
forever and isn't going anywhere anytime soon.

MultiParamTypeClasses (aka MPTCs)
This has been around forever, and is considered standard
Haskell by most people, even though it hasn't made it into the
Report yet (due the the fundeps vs TFs issue).

FunctionalDependencies (aka fundeps)
This is helpful for making certain MPTCs usable without too
many type signatures. Also, it's good for understanding the
fundeps vs TFs issue. Also, this one has been around forever,
and although it's fallen into disfavor it is still
indispensable due to limitations in TFs.

TypeFamilies (aka TFs)
These are really nifty and they're all the rage these days. In
a formal sense they're equivalent to fundeps, but in practice
they're weaker than fundeps.

GADTs
These are really nifty and they're all the rage these days.
Though beware, GADTs are a rabbit hole leading off to the world
of dependent types. You should be aware of the basic ideas
here, though don't worry too much about the theory (unless you
want to spend a lot of time worrying about the theory).

--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Most Important GHC extensions to learn/use?

2012-05-31 Thread Jonathan Geddes
Thanks, Wren, I really appreciate the detailed response! Though I am
surprised that Template Haskell isn't on your list. From the little I know
of TH it seems like all of the interesting generic/generative stuff is done
with TH. Do the other extensions subsume the need for TH, or is it just not
terribly interesting?

--J Arthur

On Thu, May 31, 2012 at 10:29 PM, wren ng thornton w...@freegeek.orgwrote:

 On 5/31/12 7:15 PM, Jonathan Geddes wrote:

 Haskell Hackers,

 I'm pretty comfortable with all of Haskell 98 (and 2010, really). But I've
 always sort of avoided extensions. I realize that this is a bit silly and
 if I want to continue learning, it probably means delving into the
 extensions. Which ones are the most important to know from a practical
 point of view? And which ones from a {Language,Category,Math}-**
 theoretical
 point of view? (Any other interesting/important points of view I'm
 missing?
 :D )


 There are a bunch which are mostly just syntax changes. The important ones
 are:

ForeignFunctionInterface (aka FFI)
Not technically part of H98, though it was a quick addition. It
is part of H2010, so it's not really an extension anymore.

ScopedTypeVariables
This one's really easy, and in the cases where you want it you
really really want it.

KindSignatures
This one's simple, and it helps expose you to the idea of
kinds, which is helpful for what's to come.

TypeOperators
This one's trivial, but it makes things a bit prettier.

FlexibleContexts, FlexibleInstances
These are essential for actually using MPTCs (described below).
IMO they should be enabled automatically whenever MPTCs are on.

 And there are also a bunch of ones about extending the deriving mechanic
 to work with new classes or with newtypes.


 Then there are the ones that actually change the language in a significant
 way. I'd say the critical ones to learn are:

RankNTypes (or Rank2Types if you're squeamish)
This is used in lots of nice tricks like list fusion. Learning
list fusion is a good place for the H98 veteran to explore
next, since it's easy to pick up and has many applications
outside of just doing list fusion. Also, it's been around
forever and isn't going anywhere anytime soon.

MultiParamTypeClasses (aka MPTCs)
This has been around forever, and is considered standard
Haskell by most people, even though it hasn't made it into the
Report yet (due the the fundeps vs TFs issue).

FunctionalDependencies (aka fundeps)
This is helpful for making certain MPTCs usable without too
many type signatures. Also, it's good for understanding the
fundeps vs TFs issue. Also, this one has been around forever,
and although it's fallen into disfavor it is still
indispensable due to limitations in TFs.

TypeFamilies (aka TFs)
These are really nifty and they're all the rage these days. In
a formal sense they're equivalent to fundeps, but in practice
they're weaker than fundeps.

GADTs
These are really nifty and they're all the rage these days.
Though beware, GADTs are a rabbit hole leading off to the world
of dependent types. You should be aware of the basic ideas
here, though don't worry too much about the theory (unless you
want to spend a lot of time worrying about the theory).

 --
 Live well,
 ~wren

 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe