Re: [Haskell-cafe] Data.Time.Calendar.Day does not seem to have an instance for Read

2011-03-17 Thread Erik Hesselink
On Thu, Mar 17, 2011 at 07:30, C K Kashyap  wrote:
>> On Thu, Mar 17, 2011 at 12:30 AM, C K Kashyap  wrote:
>> > Hi,
>> > I was wondering if this is a defect -
>> > Prelude> import Data.Time.Calendar
>> > Prelude Data.Time.Calendar> read "2011-10-10" :: Day
>> > :1:1:
>> >     No instance for (Read Day)
>> >       arising from a use of `read'
>> >     Possible fix: add an instance declaration for (Read Day)
>> >     In the expression: read "2011-10-10" :: Day
>> >     In an equation for `it': it = read "2011-10-10" :: Day
>> > Prelude Data.Time.Calendar>
>> >
>>
>> I see the same problem with GHC 7.0.2, time-1.2.0.3.
>>
>> Does it work if you use it in a Haskell source file, instead of GHCi?
>
> Nope, even compiling with ghc causes the error.

So then it's not a bug. The instance is defined in
Data.Time.Format.Parse, and Data.Time.Calendar doesn't import that
module.

This, however is a bug, I think:

Prelude> import Data.Time
Prelude Data.Time> read "2011-10-10" :: Day

... no instance for (Read Day) ...

Prelude> :m +Data.Time
Prelude Data.Time> read "2011-10-10" :: Day
2011-10-10


Erik

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


[Haskell-cafe] Weird warnings from recent GHC snapshot

2011-03-17 Thread Michael Vanier
I run haskell on Mac OS X (Snow Leopard).  After upgrading my Xcode 
installation to 4.0 I had a tricky time getting ghc working again; the 
version bundled with the Haskell Platform no longer works and I had to 
compile a recent snapshot (ghc-7.1.20110315) from source.  This worked 
fine, but now when I compile my code I keep getting really weird 
warnings.  For instance:


ld: warning: could not create compact unwind for .LFB3: non-standard 
register 5 being saved in prolog


and

SpecConstr
Function `$w$j{v s3hL} [lid]'
  has one call pattern, but the limit is 0
Use -fspec-constr-count=n to set the bound
Use -dppr-debug to see specialisations
SpecConstr
Function `$w$j{v s3ic} [lid]'
  has two call patterns, but the limit is 1
Use -fspec-constr-count=n to set the bound
Use -dppr-debug to see specialisations

The code seems to work, but this is quite irritating.  Is there anything 
that can be done about these warnings?


Thanks,

Mike



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


Re: [Haskell-cafe] Data.Time.Calendar.Day does not seem to have an instance for Read

2011-03-17 Thread C K Kashyap
>
>
> So then it's not a bug. The instance is defined in
> Data.Time.Format.Parse, and Data.Time.Calendar doesn't import that
> module.
>
> This, however is a bug, I think:
>
> Prelude> import Data.Time
> Prelude Data.Time> read "2011-10-10" :: Day
>
> ... no instance for (Read Day) ...
>
> Prelude> :m +Data.Time
> Prelude Data.Time> read "2011-10-10" :: Day
> 2011-10-10
>
>
> Erik
>

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


Re: [Haskell-cafe] Lazy evaluation and tail-recursion

2011-03-17 Thread Tillmann Rendel

Hi,

Daniel Fischer wrote:

Let's look at the following code:

countdown n = if n == 0 then 0 else foo (n - 1)


s/foo/countdown/

presumably



if' c t e = if c then t else e
countdown' n = if' (n == 0) 0 (foo (n - 1))


s/foo/countdown'/


Yes to both substitutions. Looks like I need an email client with ghc 
integration.


  Tillmann

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


Re: [Haskell-cafe] Byte Histogram

2011-03-17 Thread Gábor Lehel
Necroing this thread because I just noticed there's a (rather old!)
bug report which covers much of the same ground and doesn't seem to
have been mentioned by anyone:

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


2011/2/8 Gábor Lehel :
> 2011/2/8 Ketil Malde :
>> Gábor Lehel  writes:
>>
>>> Is there any sensible meaning for bangs on return types? I've been
>>> trying to think this through but not necessarily succeeding.
>>
>> Not knowing Clean in any detail, I've always just thought that a type
>> signature of, say:
>>
>>          something :: !Foo -> Bar
>>
>> would mean the same as, in Haskell:
>>
>>          something :: Foo -> Bar
>>          something foo = foo `seq` ...
>>
>> In this case, there's no point to a strict return type, since it would
>> boil down to "x `seq` x", which is just  "x".
>
> Yeah, this is what I keep arriving at as well, I'm not sure if there's
> another option I might be missing...
>
>>
>> But it seems that a lot of these discussions are about considering Foo
>> and !Foo distinct types, which would mean that you can no longer, say,
>> add a strict and a lazy integer - at least not with the current Num
>> instance.  I find this line of thought very confusing.
>
> As I would ideally imagine it, again, strictness would be entirely
> orthogonal to the 'normal' part of the type. So you could combine Foo
> and !Foo completely freely as if the ! had never been there. !Foo
> would be a subtype of Foo, so to speak -- !Foo representing evaluated
> values, and Foo representing either evaluated or unevaluated values.
> The ! would be an instruction to the compiler/runtime, "make sure the
> Foo is evaluated by this point", and information for the programmer,
> "the Foo is certain to be evaluated by this point". Adding !s would
> only ever result in evaluation happening, and not ever a type error.
> The advantage over bang patterns would be that the time/place of
> evaluation could be controlled by the user rather than/in addition to
> the implementer of a function/type (or at least more flexibly and
> easily than it can be done now), it would more visible, obvious, and
> certain, and perhaps type inference/elaboration could even be done.
>
> But I'm minimally well-versed in compilers and type theory, so if
> someone sees something fundamentally wrong with this idea, please
> enlighten me.
>
>>
>>> This does seem a bit excessive. As a start, I don't remember anyone
>>> asking for control over (un)boxedness, so hopefully we could jettison
>>> that part of it?
>>
>> Uh, you mean like in IOUArrays, the UNPACK pragma, or
>> -funbox-strict-fields?  Unboxing is an important optimization, but
>> perhaps the current feature set suffices.
>
> Yeah, I meant within the current context. I don't recall hearing
> complaints that control over unboxing is currently insufficient or
> that unboxing is insufficiently predictable. (But if there have been,
> feel free to fill me in...)
>
>>
>> -k
>> --
>> If I haven't seen further, it is by standing in the footprints of giants
>>
>
>
>
> --
> Work is punishment for failing to procrastinate effectively.
>



-- 
Work is punishment for failing to procrastinate effectively.

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


Re: [Haskell-cafe] How large is the Haskell community ?

2011-03-17 Thread Edward Kmett
Clearly we need some sort of xbox live -like achievement system for these.

Achievement Unlocked: Stumped Oleg!

On Sat, Feb 12, 2011 at 6:57 PM, Jan Christiansen <
j...@informatik.uni-kiel.de> wrote:

>
> On 12.02.2011, at 21:18, Aaron Gray wrote:
>
>  I was wondering if anyone had an idea or estimate as to how large the
>> Haskell community is ?
>>
>
> All the answers made me wonder what the criterion is to be a member of the
> Haskell community. Are you a member if you downloaded ghc, if you have (at
> least once) defined a Monad instance, if you have written a hackage package,
> if you have contributed to the Monad.Reader, if you have a github account
> with at least one Haskell project, if you read at least one of the haskell
> mailing lists, if you contribute to a haskell mailing list (perhaps on a
> regular basis), if you post on reddit, if you answer/ask questions on
> stackoverflow, if you have written at least 1 lines of code in Haskell,
> if Haskell is one of the programming languages you use, if Haskell is the
> one programming language you use, if you have written a PhD thesis related
> to Haskell, if you have asked a type related question only Oleg Kiselyov was
> able to answer, if you know what a Monoid is and know how to use it ... ; )
>
> Cheers, Jan
>
>
> ___
> 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] How large is the Haskell community ?

2011-03-17 Thread Yves Parès
>
http://steve-yegge.blogspot.com/2010/12/haskell-researchers-announce-discovery.html

I love the sentence "We crafted a fake satirical post lampooning Haskell as
an unusable, overly complex turd -- a writing task that was *emotionally
difficult but conceptually trivial*."
God bless self mockery ;).

> Achievement Unlocked: Stumped Oleg!

There was the Godwin point, now we have the Oleg point.
( For the layman: http://en.wikipedia.org/wiki/Godwin%27s_law )


2011/3/17 Edward Kmett 

> Clearly we need some sort of xbox live -like achievement system for these.
>
> Achievement Unlocked: Stumped Oleg!
>
>
> On Sat, Feb 12, 2011 at 6:57 PM, Jan Christiansen <
> j...@informatik.uni-kiel.de> wrote:
>
>>
>> On 12.02.2011, at 21:18, Aaron Gray wrote:
>>
>>  I was wondering if anyone had an idea or estimate as to how large the
>>> Haskell community is ?
>>>
>>
>> All the answers made me wonder what the criterion is to be a member of the
>> Haskell community. Are you a member if you downloaded ghc, if you have (at
>> least once) defined a Monad instance, if you have written a hackage package,
>> if you have contributed to the Monad.Reader, if you have a github account
>> with at least one Haskell project, if you read at least one of the haskell
>> mailing lists, if you contribute to a haskell mailing list (perhaps on a
>> regular basis), if you post on reddit, if you answer/ask questions on
>> stackoverflow, if you have written at least 1 lines of code in Haskell,
>> if Haskell is one of the programming languages you use, if Haskell is the
>> one programming language you use, if you have written a PhD thesis related
>> to Haskell, if you have asked a type related question only Oleg Kiselyov was
>> able to answer, if you know what a Monoid is and know how to use it ... ; )
>>
>> Cheers, Jan
>>
>>
>> ___
>> 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lazy evaluation and tail-recursion

2011-03-17 Thread Daniel Fischer
On Thursday 17 March 2011 13:05:33, Tillmann Rendel wrote:
> Looks like I need an email client with ghc  integration.

That would be awesome.

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


Re: [Haskell-cafe] How large is the Haskell community ?

2011-03-17 Thread Andy Stewart
> On Sat, Feb 12, 2011 at 6:57 PM, Jan Christiansen 
>  wrote:
>
> On 12.02.2011, at 21:18, Aaron Gray wrote:
>
> I was wondering if anyone had an idea or estimate as to how large the 
> Haskell community is ?
>
> All the answers made me wonder what the criterion is to be a member of 
> the Haskell
> community. Are you a member if you downloaded
> ghc, if you have (at least once) defined a Monad instance, if you have 
> written a hackage
> package, if you have contributed to the
> Monad.Reader, if you have a github account with at least one Haskell 
> project, if you read at
> least one of the haskell mailing
> lists, if you contribute to a haskell mailing list (perhaps on a regular 
> basis), if you post on
> reddit, if you answer/ask
> questions on stackoverflow, if you have written at least 1 lines of 
> code in Haskell, 
Manatee in developing, 26050 lines ... 

The real world program that written by Haskell.

http://goo.gl/MkVw
http://www.youtube.com/watch?v=weS6zys3U8k
http://www.youtube.com/watch?v=A3DgKDVkyeM

I do not care how large haskell community now, 
I only know ours efforts make haskell community become more powerful!

  -- Andy


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


Re: [Haskell-cafe] Installation of Haskell Platform on CentOS 5.5

2011-03-17 Thread Tristan Ravitch
On Thu, Mar 17, 2011 at 07:52:01AM +0100, Ketil Malde wrote:
> frode k  writes:
>
> > Installation of GHC 7.0.2 failed:
> > # ./configure --prefix=/usr/haskell-platform-2011.2.0.0/
> > checking for path to top of build tree...
> > utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.9'
> > not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
> > utils/ghc-pwd/dist/build/tmp/ghc-pwd: /lib64/libc.so.6: version `GLIBC_2.7'
> > not found (required by utils/ghc-pwd/dist/build/tmp/ghc-pwd)
> > configure: error: cannot determine current directory
>
> I eventually gave up on this, too.  Shame, I'd really like to use a
> newer GHC - did anybody succeed in compiling it on Red Hat or CentOS?
>
> -k

The ghc7 binaries are compiled against a newer version of glibc than
is available on RHEL/CentOS.  It works fine if you compile ghc7 from
source yourself (you can use 6.12 for that).


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


[Haskell-cafe] wrong backquote in haskell 2010 report Prelude

2011-03-17 Thread Albert Y. C. Lai

Haskell 2010 report chapter 9 Standard Prelude uses a wrong backquote, e.g.,

infixl 7  ⋆, /, ‘quot‘, ‘rem‘, ‘div‘, ‘mod‘

Those are U+2018. The grammar (Chapter 3) requires U+0060 and accepts no 
substitutes, e.g.,


varop → varsym | `  varid `


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


Re: [Haskell-cafe] Weird warnings from recent GHC snapshot

2011-03-17 Thread Carter Schonwald
1) if you copy the 10.5sdk from developer-old into the new developer folder
sdk folder, the standard ghc distro will work again
2) theres a ghc ticket for that, its apparently partly because theres no
-nowarnunwind flag or the like

On Thu, Mar 17, 2011 at 6:11 AM, Michael Vanier  wrote:

> I run haskell on Mac OS X (Snow Leopard).  After upgrading my Xcode
> installation to 4.0 I had a tricky time getting ghc working again; the
> version bundled with the Haskell Platform no longer works and I had to
> compile a recent snapshot (ghc-7.1.20110315) from source.  This worked fine,
> but now when I compile my code I keep getting really weird warnings.  For
> instance:
>
> ld: warning: could not create compact unwind for .LFB3: non-standard
> register 5 being saved in prolog
>
> and
>
> SpecConstr
>Function `$w$j{v s3hL} [lid]'
>  has one call pattern, but the limit is 0
>Use -fspec-constr-count=n to set the bound
>Use -dppr-debug to see specialisations
> SpecConstr
>Function `$w$j{v s3ic} [lid]'
>  has two call patterns, but the limit is 1
>Use -fspec-constr-count=n to set the bound
>Use -dppr-debug to see specialisations
>
> The code seems to work, but this is quite irritating.  Is there anything
> that can be done about these warnings?
>
> Thanks,
>
> Mike
>
>
>
> ___
> 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] tplot and splot - analyst's swiss army knifes for visualizing log files

2011-03-17 Thread Ferenc Wagner
Eugene Kirpichov  writes:

> 2010/12/17 Henning Thielemann :
>
>> Eugene Kirpichov schrieb:
>>
>>> I've published a large presentation about two Haskell-based tools of
>>> mine - tplot and splot.
>>>
>>> Their motto is "visualize system behavior from logs with a shell one-liner".
>>> Based on my experience, they usually seem to live up to this motto.
>>>
>>>
>>> http://www.slideshare.net/jkff/two-visualization-tools
>>>
>>>
>>> [attention attractor: the presentation has *really a lot* of pictures]
>>
>> ... and complete TeX code attached! :-) However can I also view a simple
>> PDF document of the presentation?
>
> You can download the PDF here -
> http://www.slideshare.net/jkff/two-visualization-tools/download
> (however one has to be logged in to Slideshare, for example with a
> facebook acct., for this link to work)
>
> Just in case, I'm also attaching a PDF of the current version to this
> email, but visiting the link is preferable, since I'll be updating the
> contents.

Please, if at all possible, link an up-to-date downloadable PDF from the
documentation (http://hackage.haskell.org/package/timeplot) or from the
homepage (http://haskell.org/haskellwiki/Timeplot) to make our life
easier!

Anyway, your tools look very interesting, I gave tplot a shot.
Unfortunately, I hit various strange failures:

$ head -4 or.log
Mar  8 18:55:11 =overrun 1
Mar  8 18:55:13 =overrun 6
Mar  8 18:55:15 =overrun 13
Mar  8 18:55:16 =overrun 3

$ wc -l or.log
466 or.log

$ ls -l or.log overruns466.log
lrwxrwxrwx 1 wferi wferi15 Mar 17 14:45 or.log -> overruns466.log
-rw-rw-r-- 1 wferi wferi 12587 Mar 17 14:35 overruns466.log

$ tplot -if or.log -tf 'date %b %e %T' -o overruns.png -k 'overrun' 'sum 10'

This worked just fine.  However, when given the same file with a longer
name, tplot does not terminate:

$ tplot -if overruns466.log -tf 'date %b %e %T' -o overruns.png -k 'overrun' 
'sum 10'
^C

while doing the same the other way around still works:

$ cat overruns466.log | tplot -if - -tf 'date %b %e %T' -o overruns.png -k 
'overrun' 'sum 10'

Choosing any other extension (svg, pdf or ps) also results in
nontermination (or at least unbearable runtime and memory consumption).

Adding a simple no-op statement, like:

diff -ur ../timeplot-0.2.19/Tools/TimePlot.hs ./Tools/TimePlot.hs
--- ../timeplot-0.2.19/Tools/TimePlot.hs2011-03-09 11:36:24.0 
+0100
+++ ./Tools/TimePlot.hs 2011-03-17 16:42:57.247625607 +0100
@@ -627,6 +627,7 @@
   when (null args || args == ["--help"]) $ showHelp >> exitSuccess
   case (readConf args) of
 Conf conf -> do
+  putStr ""
   let render = case (outFormat conf) of {
   PNG-> \c w h f -> const () `fmap` renderableToPNGFile c w h f;
   PDF-> renderableToPDFFile ;

also results in nontermination, even in the previously working case.
Something is clearly wrong here, seemingly in the runtime IO system.
-- 
Thanks,
Feri.

GHC 6.12.1
Chart-0.14
bytestring-0.9.1.5
bytestring-lexing-0.2.1
cairo-0.11.0
colour-2.3.1
containers-0.3.0.0
data-accessor-0.2.1.3
data-accessor-template-0.2.1.7
haskell98-1.0.1.1
regex-tdfa-1.1.4
strptime-1.0.1
time-1.1.4

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


[Haskell-cafe] Haskell report minutiae

2011-03-17 Thread wren ng thornton
So I have a rules-lawyering question about how specified the overflow 
behavior is for the types Int and Word.


* In the Haskell 2010 report it seems to be specified that (sections 
18.1, 23.1): "All arithmetic is performed modulo 2^n, where n is the 
number of bits in the type." And this seems to apply to Int and Word as 
well as Int8, Word8, Int16, Word16, Int32, Word32, Int64, Word64.


* However, in the Haskell 98 report ---and this verbiage is retained in 
the same section of H2010--- there is no such guarantee (section 6.4): 
"The results of exceptional conditions (such as overflow or underflow) 
on the fixed-precision numeric types are undefined; an implementation 
may choose error (_|_, semantically), a truncated value, or a special 
value such as infinity, indefinite, etc."


* However, the FFI addendum to H98 does specify modulo behavior for the 
Int8, Word8, Int16, Word16, Int32, Word32, Int64, Word64 types (section 
5.3): "There is, however, the additional constraint that all arithmetic 
on the fixed-sized types is performed modulo 2^n." But it is unclear 
whether this also applies to Int and Word.



So when it comes to interpreting the report(s) and ensuring proper 
implementation, which is it? Are Int and Word arithmetic modular, or 
not? Did the specification change between H98 and H98+FFI or between 
H98+FFI and H2010?


--
Live well,
~wren

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


[Haskell-cafe] Defining subtraction for naturals

2011-03-17 Thread wren ng thornton
Another question on particulars. When dealing with natural numbers, we 
run into the problem of defining subtraction. There are a few reasonable 
definitions:


(1) If the result would drop below zero then throw an overflow error;

(2) Use saturating subtraction, i.e. if the result would drop below zero 
then return zero;


(3) Use type hackery to disallow performing subtraction when the result 
would drop below zero, e.g. by requiring a proof that the left argument 
is not less than the right.


Dependently typed languages tend to use the second definition because it 
gives a pure total function (unlike the first) and because it's less 
obnoxious to use than the third. In Haskell the third would be even more 
obnoxious.


So my question is, mathematically speaking, is there any reason to 
prefer the second option over the first or third? Purity aside, I mean; 
do the natural numbers with saturating subtraction form any interesting 
mathematical object, or is it just what we're stuck with?



In a similar vein. Given a finite set (e.g., the natural numbers with 
some finite upper bound) and assuming we've already decided not to use 
modular arithmetic, is there any mathematical reason to prefer 
saturating addition and/or multiplication instead of throwing an 
overflow error?


--
Live well,
~wren

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread Luke Palmer
If you are implementing lazy naturals, I wonder if defining 0 - 1 to
be infinity makes mathematical sense.  It's like arithmetic mod
infinity

Luke

On Thu, Mar 17, 2011 at 12:35 PM, wren ng thornton  wrote:
> Another question on particulars. When dealing with natural numbers, we run
> into the problem of defining subtraction. There are a few reasonable
> definitions:
>
> (1) If the result would drop below zero then throw an overflow error;
>
> (2) Use saturating subtraction, i.e. if the result would drop below zero
> then return zero;
>
> (3) Use type hackery to disallow performing subtraction when the result
> would drop below zero, e.g. by requiring a proof that the left argument is
> not less than the right.
>
> Dependently typed languages tend to use the second definition because it
> gives a pure total function (unlike the first) and because it's less
> obnoxious to use than the third. In Haskell the third would be even more
> obnoxious.
>
> So my question is, mathematically speaking, is there any reason to prefer
> the second option over the first or third? Purity aside, I mean; do the
> natural numbers with saturating subtraction form any interesting
> mathematical object, or is it just what we're stuck with?
>
>
> In a similar vein. Given a finite set (e.g., the natural numbers with some
> finite upper bound) and assuming we've already decided not to use modular
> arithmetic, is there any mathematical reason to prefer saturating addition
> and/or multiplication instead of throwing an overflow error?
>
> --
> Live well,
> ~wren
> ___
> Agda mailing list
> a...@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread wren ng thornton

On 3/17/11 2:50 PM, Luke Palmer wrote:

If you are implementing lazy naturals, I wonder if defining 0 - 1 to
be infinity makes mathematical sense.  It's like arithmetic mod
infinity


Actually, I'm specifically implementing strict naturals :)

There are a number of libraries for lazy naturals out there already, but 
for my current project I need the efficiency of Int/Integer--- without 
the errors or defensive programming that comes from using them when we 
mean Nat/Natural.


So far I haven't actually needed arithmetic operations (Enum, Eq, and 
Ord have been enough) but I figure I should square that away before 
splitting the code off for a public release. Since the whole thing is 
done as newtypes I can always make the Num instances the "right" ones, 
since people who obsess over performance can manually unwrap them to 
perform raw operations they know/hope will succeed and then revalidate 
the invariants when they're done with the arithmetic section. I just 
want to make sure the instance I give has the nice mathematical 
properties it could/should.


--
Live well,
~wren

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


Re: [Haskell-cafe] Defining subtraction for naturals

2011-03-17 Thread Henning Thielemann


On Thu, 17 Mar 2011, wren ng thornton wrote:


(1) If the result would drop below zero then throw an overflow error;

(2) Use saturating subtraction, i.e. if the result would drop below zero then 
return zero;


(3) Use type hackery to disallow performing subtraction when the result would 
drop below zero, e.g. by requiring a proof that the left argument is not less 
than the right.


My practical experiences with the non-negative package are: I started with 
a saturation subtraction as in (2), but it turned out, that I hardly need 
that definition in further code. Thus I switched to


(4) Use a symmetric subtraction that returns the minimum, the order and 
the absolute difference of both operands. Precise definitions and reasons 
in 'split' function:


http://hackage.haskell.org/packages/archive/non-negative/0.1/doc/html/Numeric-NonNegative-Class.html


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


Re: [Haskell-cafe] Defining subtraction for naturals

2011-03-17 Thread David Menendez
On Thu, Mar 17, 2011 at 2:35 PM, wren ng thornton  wrote:
> Another question on particulars. When dealing with natural numbers, we run
> into the problem of defining subtraction. There are a few reasonable
> definitions:
>
> (1) If the result would drop below zero then throw an overflow error;
>
> (2) Use saturating subtraction, i.e. if the result would drop below zero
> then return zero;
>
> (3) Use type hackery to disallow performing subtraction when the result
> would drop below zero, e.g. by requiring a proof that the left argument is
> not less than the right.
>
> Dependently typed languages tend to use the second definition because it
> gives a pure total function (unlike the first) and because it's less
> obnoxious to use than the third. In Haskell the third would be even more
> obnoxious.
>
> So my question is, mathematically speaking, is there any reason to prefer
> the second option over the first or third? Purity aside, I mean; do the
> natural numbers with saturating subtraction form any interesting
> mathematical object, or is it just what we're stuck with?

In "What About the Natural Numbers", Colin Runciman argues for
definition 2, but he doesn't provide much analysis beyond noting that
it gives you

length (drop n xs) = length xs - n

He also argues for setting x / 0 = x for strict naturals or x / 0 =
infinity for lazy naturals.

There are some use cases for both in the paper.

-- 
Dave Menendez 


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


Re: [Haskell-cafe] How large is the Haskell community ?

2011-03-17 Thread wren ng thornton

On 3/17/11 9:18 AM, Andy Stewart wrote:

On Sat, Feb 12, 2011 at 6:57 PM, Jan Christiansen  
wrote:
if you have written at least 1 lines of code in Haskell,


Goodness. It looks like my current project is over 17,275 lines 
including documentation but excluding testing code (of which 2,557 are 
Java client code and 2,686 were prior work). I knew it was getting big, 
but not that big...


--
Live well,
~wren

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread Nils Anders Danielsson

On 2011-03-17 19:35, wren ng thornton wrote:

Dependently typed languages tend to use the second definition because it
gives a pure total function (unlike the first) and because it's less
obnoxious to use than the third. In Haskell the third would be even more
obnoxious.


There is a fourth option: a comparison view. See "The view from the
left" by Conor McBride and James McKinna (Section 6).

(This option is similar to what Henning Thielemann suggested.)

--
/NAD

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


[Haskell-cafe] DSL for task dependencies

2011-03-17 Thread Serge Le Huitouze
Hi Haskellers!

I think I remember reading a blog post or web page describing a
EDSL to describe tasks and their dependencies "a la" make.

Can anyone point me to such published material?

Thanks in advance.

--serge

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


Re: [Haskell-cafe] How large is the Haskell community ?

2011-03-17 Thread Vo Minh Thu
2011/3/17 wren ng thornton :
> On 3/17/11 9:18 AM, Andy Stewart wrote:
>>>
>>> On Sat, Feb 12, 2011 at 6:57 PM, Jan
>>> Christiansen  wrote:
>>> if you have written at least 1 lines of code in Haskell,
>
> Goodness. It looks like my current project is over 17,275 lines including
> documentation but excluding testing code (of which 2,557 are Java client
> code and 2,686 were prior work). I knew it was getting big, but not that
> big...

Mm. Do 12000 lines of auto-generated code[0] count?

[0] https://github.com/noteed/hblend/blob/master/Data/Blend/B245.hs

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


Re: [Haskell-cafe] DSL for task dependencies

2011-03-17 Thread David Peixotto
Hi Serge,

You may be thinking of the Shake DSL presented by Neil Mitchell at last years 
Haskell Implementers Workshop. Slides and video are available from: 
http://haskell.org/haskellwiki/HaskellImplementorsWorkshop/2010

Max Bolingbroke has an open source implementation available here: 
https://github.com/batterseapower/openshake

Hope that helps.

-David

On Mar 17, 2011, at 3:00 PM, Serge Le Huitouze wrote:

> Hi Haskellers!
> 
> I think I remember reading a blog post or web page describing a
> EDSL to describe tasks and their dependencies "a la" make.
> 
> Can anyone point me to such published material?
> 
> Thanks in advance.
> 
> --serge
> 
> ___
> 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] How large is the Haskell community ?

2011-03-17 Thread Mark Lentczner
On Thu, Mar 17, 2011 at 1:25 PM, Vo Minh Thu  wrote:

> Mm. Do 12000 lines of auto-generated code[0] count?
>
>
Yes: The generator gets to be a member of the Haskell community!  :-)

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


Re: [Haskell-cafe] ANN: Monad.Reader special Poetry and Fiction Edition

2011-03-17 Thread Andrew Coppin

I think we should have a wiki page somewhere which explains what all
the various Haskell-related terms mean. Terms like "typing the knot"
and "finally tagless". (Not to mention "Oleg rating"...)


I have created such a page:
http://www.haskell.org/haskellwiki/Terms


Defining "unlifted type" without defining "bottom" probably isn't very 
helpful. (I'm sure there's already a wiki page for it though...)


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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread Conor McBride


On 17 Mar 2011, at 18:35, wren ng thornton wrote:

Another question on particulars. When dealing with natural numbers,  
we run into the problem of defining subtraction. There are a few  
reasonable definitions:


No there aren't.

Conor


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


Re: [Haskell-cafe] Byte Histogram

2011-03-17 Thread Andrew Coppin

On 17/03/2011 12:11 PM, Gábor Lehel wrote:

Necroing this thread because I just noticed there's a (rather old!)
bug report which covers much of the same ground and doesn't seem to
have been mentioned by anyone:

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


Right. So somebody else came up with an idea similar to mine, but since 
nobody could agree on anything more than a rough idea, nothing actually 
got done...(?)


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


Re: [Haskell-cafe] Wanted: composoable parsers from haskell-src-exts

2011-03-17 Thread Niklas Broberg
> >  I already export a partial parser for top-of-file pragmas,
>
> I see. What I don't see is how such a parser would return the "rest of
input".

Hmm. I see. And I see that you are correct in not seeing it, since it
appears it cannot be done with Happy, which I believed. It would then be
down to the parser/lexer to pass on unconsumed input, which seems a daunting
and disruptive task, seeing how the lexer typically would tokenize some
input in advance before the parser discovers that it cannot consume what has
been lexed... Hmm.

I still find it a highly desirable feature, and at some point I would like
to give it some further thought, to see if a way can be found. In the mean
time, would you mind filing a feature request at
http://trac.haskell.org/haskell-src-exts ?

Cheers,

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


Re: [Haskell-cafe] Byte Histogram

2011-03-17 Thread Gábor Lehel
On Thu, Mar 17, 2011 at 10:37 PM, Andrew Coppin
 wrote:
> On 17/03/2011 12:11 PM, Gábor Lehel wrote:
>>
>> Necroing this thread because I just noticed there's a (rather old!)
>> bug report which covers much of the same ground and doesn't seem to
>> have been mentioned by anyone:
>>
>> http://hackage.haskell.org/trac/ghc/ticket/1349
>
> Right. So somebody else came up with an idea similar to mine, but since
> nobody could agree on anything more than a rough idea, nothing actually got
> done...(?)

Well, I also got the sense that it would be more than a little
nontrivial to implement. Or at least, someone was talking about how it
would be a good topic for writing a thesis about if someone managed to
figure how to do it. I suspect that if someone were to actually put in
the effort they would be afforded the privilege of getting to nail
down the details. That's just completely baseless speculation, though.

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



-- 
Work is punishment for failing to procrastinate effectively.

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


Re: [Haskell-cafe] Byte Histogram

2011-03-17 Thread Andrew Coppin

Right. So somebody else came up with an idea similar to mine, but since
nobody could agree on anything more than a rough idea, nothing actually got
done...(?)


Well, I also got the sense that it would be more than a little
nontrivial to implement. Or at least, someone was talking about how it
would be a good topic for writing a thesis about if someone managed to
figure how to do it. I suspect that if someone were to actually put in
the effort they would be afforded the privilege of getting to nail
down the details. That's just completely baseless speculation, though.


That sounds like a good description for just about every imaginable 
extension to Haskell that does something interesting! :-D


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


Re: [Haskell-cafe] Defining subtraction for naturals

2011-03-17 Thread wren ng thornton

On 3/17/11 3:30 PM, David Menendez wrote:

In "What About the Natural Numbers", Colin Runciman argues for [...]


Thanks for the reference, I'll go check it out.

--
Live well,
~wren

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


Re: [Haskell-cafe] X11 package bug: XClientMessageEvent long data

2011-03-17 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 3/16/11 00:10 , Dylan Alex Simon wrote:
> Does anyone know the current maintenance status of the X11 package?  I emailed
> Spencer Janssen a number of months ago and never heard back.  So, I'll put
> this here in case any one else runs into it or can get it to the right place.
> 
> This is a proposed bug fix for a problem I ran into using xmonad client
> messages to send remote commands on 64LP architectures (i.e., amd64), wherein
> the C X11 library and Haskell's disagree about the size of client message
> arguments.
> 
> Tue Nov 16 23:41:49 EST 2010  Dylan Simon 
>   * change XClientMessageEvent long data
>   
>   The XClientMessageEvent.data.l field is actually a long, not an int, so it 
> must
>   be interpreted as such, even though format is set to 32 in this case.
>   Ostensibly this is an Xlib bug, but it is unlikely to be fixed there.

I believe it's documented behavior (in XLib).  In any case, that's only one
of several problems with client messages (and properties).  It's on the
list... somewhere.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com
system administrator  [openafs,heimdal,too many hats]kf8nh
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2CiEoACgkQIn7hlCsL25XezACdH8w+tE7FveanJvA8s/1RQQQD
SVEAnA88zbzt+1dRzMR7Maq7H4kLEVBg
=Hb3q
-END PGP SIGNATURE-

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread wren ng thornton

On 3/17/11 4:22 PM, Martin Escardo wrote:

On 17/03/11 18:35, wren ng thornton wrote:

(2) Use saturating subtraction, i.e. if the result would drop below zero
then return zero;


This is what people working with quantales do.

Subtraction y-z, when it exists, is the solution in s to the equation
s+z =y.

Truncated subtraction y - z is the supremum of the set of solutions s to
the inequality s+z <= y, when this supremum exists. (In your example,
when z>y, the set of solutions is empty, and the empty set has supremum
zero.)

This amounts to saying that the truncated subtraction function (-) - z
is the right adjoint to the addition function (-) + z.

So (2) is very natural.


Thanks! That's exactly the kind of thing I was looking for. I'd been 
needlessly thinking of it as a hack :)


--
Live well,
~wren

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread wren ng thornton

On 3/17/11 5:12 PM, Conor McBride wrote:

On 17 Mar 2011, at 18:35, wren ng thornton wrote:

Another question on particulars. When dealing with natural numbers, we
run into the problem of defining subtraction. There are a few
reasonable definitions:


No there aren't.


How about "pragmatically efficacious"?

--
Live well,
~wren

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


Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread Edward Kmett
On Thu, Mar 17, 2011 at 6:41 PM, wren ng thornton  wrote:

> On 3/17/11 5:12 PM, Conor McBride wrote:
>
>> On 17 Mar 2011, at 18:35, wren ng thornton wrote:
>>
>>> Another question on particulars. When dealing with natural numbers, we
>>> run into the problem of defining subtraction. There are a few
>>> reasonable definitions:
>>>
>>
>> No there aren't.
>>
>
> How about "pragmatically efficacious"?
>

If you must, you could always fall back on an encoding similar to the one
that Brent used when introducing virtual species:

http://byorgey.wordpress.com/2010/11/24/species-subtraction-made-simple/

along with some setoid that normalized for comparison on them, or you could
just switch to type level Integers.

-Edward


> --
> Live well,
> ~wren
>
> ___
> Agda mailing list
> a...@lists.chalmers.se
> https://lists.chalmers.se/mailman/listinfo/agda
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ghci Vim completion within Vim - need some advice

2011-03-17 Thread Marc Weber
Hi,

https://github.com/MarcWeber/vim-addon-async
implements a hacky way to run external processes asynchronously.
An external helper application send stdout of the process to Vim which
adds the bytes to the buffer.

Its not perfect but quite usable.

Now I'd like to show the completion of \t sent to ghci to the user.

I've done so for Ruby, Python and Scala: Vim sends input to ghci, and
the reply is catched and put into Vim's completion list.

issue 1): ghci's tab only works if its connected to a "terminal".
  This can be fixed easily by using a pseudo terminal

issue 2): ghci's prompt sends data to /dev/tty (the controlling
  terminal) rather than to stdout/err.

I don't know how to fix issue 2). Any ideas?

The result could look like this python REPL screenshot:
http://mawercer.de/~marc/vim-addon-async-python-repl.jpg

Marc Weber

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


[Haskell-cafe] How to contact OpenGL package maintainer (where is Sven?)

2011-03-17 Thread Jason Dagit
Hello,

It looks like the OpenGL packages on hackage[1,2,3,4] have not been updated
in some time.  No updates later than Oct 2009.  I tried to email Sven
directly using the email address listed on hackage but after about a week I
still haven't heard from him.  I sent some patches to the opengl list
yesterday, and then today I noticed that Sven hasn't posted on that list
since Oct 2009 when he released the current version of OpenGLRaw.  None of
the public darcs repos have patches newer than Oct 2009.  Also, the homepage
url listed in the packages is a 404:
http://www.haskell.org/HOpenGL/

My concern is that Sven has disappeared for some reason.  I hope he's well.
 He has always done top notch work in the past maintaining these libraries.
 Perhaps he's simply busy or lost interest?

Does anyone know if he was looking for a new maintainer?  Perhaps you've
heard from him more recently than Oct 2009?

If a new maintainer is needed, I would consider nominating myself :)

Thanks,
Jason

[1] http://hackage.haskell.org/package/OpenGLRaw
[2] http://hackage.haskell.org/package/OpenGL
[3] http://hackage.haskell.org/package/GLURaw
[4] http://hackage.haskell.org/package/GLUT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] DSL for task dependencies

2011-03-17 Thread Conal Elliott
Speaking of which, for a while now I've been interested in designs of
make-like systems that have precise & simple (denotational) semantics with
pleasant properties. What Peter Landin called "denotative" (as opposed to
functional-looking but semantically ill-defined or intractable).

Norman Ramsey (cc'd) pointed me to the
Vestasystem
from DEC SRC. If anyone knows of other related experiments, I'd
appreciate hearing.

  - Conal

On Thu, Mar 17, 2011 at 1:31 PM, David Peixotto  wrote:

> Hi Serge,
>
> You may be thinking of the Shake DSL presented by Neil Mitchell at last
> years Haskell Implementers Workshop. Slides and video are available from:
> http://haskell.org/haskellwiki/HaskellImplementorsWorkshop/2010
>
> Max Bolingbroke has an open source implementation available here:
> https://github.com/batterseapower/openshake
>
> Hope that helps.
>
> -David
>
> On Mar 17, 2011, at 3:00 PM, Serge Le Huitouze wrote:
>
> > Hi Haskellers!
> >
> > I think I remember reading a blog post or web page describing a
> > EDSL to describe tasks and their dependencies "a la" make.
> >
> > Can anyone point me to such published material?
> >
> > Thanks in advance.
> >
> > --serge
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe