Re: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1

2008-10-08 Thread Don Stewart
lrpalmer:
Several very elegant FRP approaches are emerging, most visibly
FRP.Reactive, which rely on blocking on multiple variables at once,
continuing when the *first* of them is available. . . inside an
unsafePerformIO, so the beautiful STM orElse solution is not available.
 The current solution is to race threads against each other, and have the
one that finishes first kill the other one.  This is implemented, for
example, in Data.Unamb.  However, our empirical tests have shown that the
GHC scheduler is not *quite* good enough to handle this efficiently, and
ends up introducing too much latency and nondeterminacy.

Cool! Does you IVar implementation have anything in common with previous
proposals for things called IVar (or say, 'ports',
http://www.cse.unsw.edu.au/~chak/haskell/ports/)?

What's the background for this abstraction?

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


Re: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1

2008-10-08 Thread Luke Palmer
On Wed, Oct 8, 2008 at 12:20 AM, Don Stewart [EMAIL PROTECTED] wrote:

 lrpalmer:
 Several very elegant FRP approaches are emerging, most visibly
 FRP.Reactive, which rely on blocking on multiple variables at once,
 continuing when the *first* of them is available. . . inside an
 unsafePerformIO, so the beautiful STM orElse solution is not
 available.
  The current solution is to race threads against each other, and have
 the
 one that finishes first kill the other one.  This is implemented, for
 example, in Data.Unamb.  However, our empirical tests have shown that
 the
 GHC scheduler is not *quite* good enough to handle this efficiently,
 and
 ends up introducing too much latency and nondeterminacy.

 Cool! Does you IVar implementation have anything in common with previous
 proposals for things called IVar (or say, 'ports',
 http://www.cse.unsw.edu.au/~chak/haskell/ports/http://www.cse.unsw.edu.au/%7Echak/haskell/ports/
 )?


Yes, I picked up the name from haskell-cafe discussions a while back.
Various forms have been popping in and out of the reactive libraries.

I hadn't seen ports before.

What's the background for this abstraction?


So like I said, I'm not too sure, I just stole the name and vague idea from
discussions about it.  As is easily noticed from the jive above, it's
motivated by the continuous barrage of suboptimal FRP libraries.  While I'm
working on reactive from the top down, this is the beginning of one I have
planned, taking baby steps from the bottom up  (and it'll likely get
incorporated into reactive too).

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


Re: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1

2008-10-08 Thread Sean Leather
forkIO $ threadDelay 1000  writeIVar iv' my spoon is too big


   writeIVar iv' i am a banana   -- throws error IVar written twice


Nice Don Hertzfeldt reference. ;)

If this means nothing to you, here's the animated film from whence this
came:
  http://www.youtube.com/watch?v=MuOvqeABHvQ

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


Re: [Haskell-cafe] Hoogle? [Stacking monads]

2008-10-08 Thread Ryan Ingram
On Tue, Oct 7, 2008 at 7:09 PM, Andrew Coppin
[EMAIL PROTECTED] wrote:
 For my current troubles, it would be really useful if there were some
 program that you could feed some source code to, and it would tell you what
 the inferred types of each subexpression are. (Ideally it would be nice if
 you could use this on fragments that don't typecheck; being able to see what
 types are being inferred where could help explain why the type checker is
 unhappy, and ultimately where you went wrong. But I'm not sure how you could
 present the internal state in a digestible way.) I don't know if anybody has
 ever attempted such a tool...?

There is such a tool, it's called ghci :)
It just takes a bit of massaging to do what you want:

... some module code ...

{-
function_that_does_not_typecheck = some_expression
-}
function_that_does_not_typecheck = error force typechecker to be happy

For now lets assume that you are curious about the type of the subexpression
   f some_func [a..b]

where f, a, and b are locally bound.

Then

ghci :set -fglasgow-exts
ghci :t (?f some_func [?a .. ?b])

Here's an example:
Prelude :t ?f map [?a .. ?b]
?f map [?a .. ?b] :: forall t a b t1.
 (Enum t1,
?b::t1,
?a::t1,
?f::((a - b) - [a] - [b]) - [t1] - t)
 = t

This tells you the types the variables have to have, and the type of
the expression.

Judicious use of (undefined :: type_signature) can also help.

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


RE: [Haskell-cafe] Darcs / Git

2008-10-08 Thread Mitchell, Neil

 Yes, I've used SSH key. Didn't think it would be different 
 with a password.

It really is! :-)

Thanks

Neil

 
 On 7 Oct 2008, at 20:19, Mitchell, Neil wrote:
 
 
 
  I use darcs on Windows every day and it works well. The
  only problem
  is that it is not very usable if you access your 
 repository via SSH 
  and the authentication is via password.
 
  Why not? It worked fine for me.
 
  It's never worked for me, I always get a frozen darcs 
 trying to read a 
  password, but not from my console.
 
  If you connect with an SSH key its more secure and less 
 typing - it's 
  a better way to go.
 
  Thanks
 
  Neil
 
  =
  =
  =
  =
  =
  =
  =
  =
  
 ==
  Please access the attached hyperlink for an important electronic 
  communications disclaimer:
 
  http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
  =
  =
  =
  =
  =
  =
  =
  =
  
 ==
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 

==
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==

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


[Haskell-cafe] [hmatrix] build error

2008-10-08 Thread Xiao-Yong Jin
Hi, looks like I hit a bug, but I'm not sure which software
it belongs to, gcc, ghc or atlas?

-- error doing runhaskell Setup build --
Preprocessing library hmatrix-0.4.1.0...
/usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol 
`__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) 
isreferenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed
command was: /usr/bin/ghc -optl-lgsl -optl-llapack 
dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o 
dist/build/Numeric/GSL/Special/Internal_hsc_make
-- error doing runhaskell Setup build --

I believe `__powidf2' is a internal symbol in gcc and it is
hidden.

The system is archlinux x86_64 and the software I used are

atlas-lapack 3.8.2-1

gcc 4.3.2-1
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix 
--mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit 
--disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu 
--disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.3.2 (GCC)

ghc 6.8.2-2
 [(Project name,The Glorious Glasgow Haskell Compilation System)
 ,(Project version,6.8.2)
 ,(Booter version,6.8.2)
 ,(Stage,2)
 ,(Interface file version,6)
 ,(Have interpreter,YES)
 ,(Object splitting,YES)
 ,(Have native code generator,YES)
 ,(Support SMP,YES)
 ,(Unregisterised,NO)
 ,(Tables next to code,YES)
 ,(Win32 DLLs,)
 ,(RTS ways, debug  thr thr_p thr_debug)
 ,(Leading underscore,NO)
 ]

I googled but no useful information.

Best,
Xiao-Yong
-- 
c/*__o/*
\ * (__
*/\  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [hmatrix] build error

2008-10-08 Thread Xiao-Yong Jin
Xiao-Yong Jin [EMAIL PROTECTED] writes:

 Hi, looks like I hit a bug, but I'm not sure which software
 it belongs to, gcc, ghc or atlas?

 -- error doing runhaskell Setup build --
 Preprocessing library hmatrix-0.4.1.0...
 /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol 
 `__powidf2' in 
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced 
 by DSO
 /usr/bin/ld: final link failed: Nonrepresentable section on output
 collect2: ld returned 1 exit status
 linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed
 command was: /usr/bin/ghc -optl-lgsl -optl-llapack 
 dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o 
 dist/build/Numeric/GSL/Special/Internal_hsc_make
 -- error doing runhaskell Setup build --

It might be a problem of atlas.  With Intel's MKL, it builds
fine.
-- 
c/*__o/*
\ * (__
*/\  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Functional dependencies and incoherent instances

2008-10-08 Thread Tobias Bexelius
Hi,

Im trying to overload a multiplication operator for scalars and vectors,
but keep running into the error message Functional dependencies
conflict. What I think is going on is that the dependency check doesn't
work with incoherent (or overlapping) instances. In the example below,
the two instances of Mult are overlapping. What I want is the vector
version to be used for vectors and the scalar version used for numbers,
even if a vector-type is an instance of the Num-class (I believe
-fallow-incoherent-instances would make that kind of choise for me,
right?).

Im using the Visual Studio plugin Visual Haskell, and thus GHC version
6.6. Otherwise I think associated types might have worked better for
this...

Regards
Tobias Bexelius



{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances
-fallow-incoherent-instances #-}

data V2 a = V2 a a

class Vec v a where
dot :: v a - v a - a
instance Num a = Vec V2 a where
V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2

class Mult a b c | a b - c where
(*.) :: a - b - c
instance (Num x) = Mult x x x where (*.) = (*)
instance (Vec a x) = Mult (a x) (a x) x where (*.) = dot
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] OT: Haskell desktop wallpaper?

2008-10-08 Thread Magnus Therning
This morning I got tired of my desktop wallpaper (one that ships with
Debian's Gnome packages).  Typing haskell desktop wallpaper yeilded
a lot of links to wallpapers with Colleen Haskell, while she's a
beautiful lady it wasn't exactly what I was hoping to find.  Hence
this email.  Where can I find some nice wallpapers inspired by
Haskell, or maybe even created by Haskell code?

Oh yes, wallpapers related to XMonad would do, I suppose ;-)

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Type classes question

2008-10-08 Thread Roly Perera
Ryan Ingram ryani.spam at gmail.com writes:

 [...]
 
 Here's another possible solution:
 
  newtype AsFunctor s a = AF { fstream :: (s a) }
  instance (Stream f) = Functor (AsFunctor f) where
  fmap f (AF s) = AF (fmapStreamDefault f s)
 
 Now to use fmap you wrap in AF and unwrap with fstream.
 
 None of the existing solutions are really satisfactory, unfortunately.

Bulat Ziganshin bulat.ziganshin at gmail.com writes:

 http://haskell.org/haskellwiki/OOP_vs_type_classes may be useful
 
Many thanks to you both for the clarification and pointers.

cheers,
Roly



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


Re: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1

2008-10-08 Thread Jake Mcarthur

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Oct 8, 2008, at 7:28 AM, Jake Mcarthur wrote:

 I'm attaching one of the more well-known variants in case anybody  
is interested, although to be honest I can't remember which one was  
actually the best as I have moved on from this approach.


I just looked back over it. I had forgotten how far from the original  
idea I had gone. Perhaps this would be better with a different name now.


- - Jake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkjsqI4ACgkQye5hVyvIUKm/dQCfbzNfeTZTzmPQa6a2ZwGkqlbp
ZZUAn2V5NrX1zR549EsEm8Oj5psU4fl6
=8vsl
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OT: Haskell desktop wallpaper?

2008-10-08 Thread Dougal Stanton
2008/10/8 Magnus Therning [EMAIL PROTECTED]:
 This morning I got tired of my desktop wallpaper (one that ships with
 Debian's Gnome packages).  Typing haskell desktop wallpaper yeilded
 a lot of links to wallpapers with Colleen Haskell, while she's a
 beautiful lady it wasn't exactly what I was hoping to find.  Hence
 this email.  Where can I find some nice wallpapers inspired by
 Haskell, or maybe even created by Haskell code?

It shouldn't be too difficult to generate some wallpapers. Look at the
examples included with the Diagrams package [1]. You could take the
Ford circles and have different coloured circles at every startup. You
could even have a range of palettes depending on season ;-)


[1]: http://code.haskell.org/diagrams/example/examples.html


Cheers,

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


[Haskell-cafe] Re: I'll do USB in Haskell - tips?

2008-10-08 Thread Mauricio

Looking for Posix Linux API, I found www.linux-usb.org. It
has a lot (I think all I need) to start in Linux. Does anyone
knows where can I find related information for Windows, so
I can start without writing something that would be difficult
to support there?

Best,
Maurício


Hello,

I am also interested in SCSI, PCI, etc. (...)  Maybe Marco
should talk to the people doing the Linux implementation for the Posix 
API and see how viable that API is before spending a  year for nothing.  
Or Marco maybe you can be a trailblazer and come up with a better 
Posix/Win32 USB APIquo t; and implement in Haskell? ;^)


Very kind regards, Vasili


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


[Haskell-cafe] Call for Contributions - Haskell Communities and Activities Report, November 2008 edition

2008-10-08 Thread Janis Voigtlaender

Dear Haskellers,

so much has happened in the Haskell world in the past months.
Therefore, I would very much like to collect contributions for
the 15th edition of the

   
   Haskell Communities  Activities Report
 http://www.haskell.org/communities/

Submission deadline: 31 October 2008

   (please send your contributions to [EMAIL PROTECTED], in
  plain text or LaTeX format)
   

This is the short story:

* If you are working on any project that is in some way related
  to Haskell, please write a short entry and submit it. Even if
  the project is very small or unfinished or you think it is not
  important enough -- please reconsider and submit an entry anyway!

* If you are interested in any project related to Haskell that has not
  previously been mentioned in the HCA Report, please tell me, so that
  I can contact the project leaders and ask them to submit an entry.

* Feel free to pass on this call for contributions to others that
  might be interested.

More detailed information:

The Haskell Communities  Activities Report is a bi-annual overview of
the state of Haskell as well as Haskell-related projects over the
last, and possibly the upcoming six months. If you have only recently
been exposed to Haskell, it might be a good idea to browse the
May 2008 edition -- you will find interesting topics described as
well as several starting points and links that may provide answers to
many questions.

Contributions will be collected until the submission deadline. They
will then be compiled into a coherent report that is published online
as soon as it is ready. As always, this is a great opportunity to
update your webpages, make new releases, announce or even start new
projects, or to talk about developments you want every Haskeller to
know about!

Looking forward to your contributions,

Janis (current editor)


FAQ:

Q: What format should I write in?

A: The best format is a LaTeX source file, adhering to the template
that is available at:

   http://haskell.org/communities/11-2008/template.tex

There is also a LaTeX style file at

   http://haskell.org/communities/11-2008/hcar.sty

that you can use to preview your entry. If you do not know LaTeX, then
use plain text. If you modify an old entry that you have written for an
earlier edition of the report, you should have received your old entry
as a template already (provided I have your valid email address).
Please modify that template, rather than using your own version of the
old entry as a template. Do not worry about writing correct LaTeX, I
will be able to handle your file. Please do not use HTML or even DOC.

Q: Can I include images?

A: Yes, you are even encouraged to do so. Please use .jpg format, then.

Q: How much should I write?

A: Authors are asked to limit entries to about one column of text. This
corresponds to approximately one page, or 40 lines of text, with the
above style and template.

A general introduction is helpful. Apart from that, you should focus on
recent or upcoming developments. Pointers to online content can be given
for more comprehensive or ``historic'' overviews of a project. Images do
not count towards the length limit, so you may want to use this
opportunity to pep entries up. There is no minimum length of an entry!
The report aims at being as complete as possible, so please consider
writing an entry, even if it is only a few lines long.

Q: Which topics are relevant?

A: All topics which are related to Haskell in some way are relevant. We
usually had reports from users of Haskell (private, academic, or
commercial), from authors or contributors to projects related to
Haskell, from people working on the Haskell language, libraries, on
language extensions or variants. We also like reports over distributions
of Haskell software, Haskell infrastructure, books and tutorials on
Haskell. Reports on past and upcoming events related to Haskell are also
relevant. Finally, there might be new topics we do not even think about.
As a rule of thumb: if in doubt, then it probably is relevant and has a
place in the HCAR. You can also ask the editor.

Q: Is unfinished work relevant? Are ideas for projects relevant?

A: Yes! You can use the HCAR to talk about projects you are currently
working on. You can use it to look for other developers that might help
you. You can use it to write ``wishlist'' items for libraries and
language features you would like to see implemented.

Q: If I do not update my entry, but want to keep it in the report, what
should I do?

A: Tell the editor that there are no changes. The old entry will be
reused in this case, but it might be dropped if it is older than a year,
to give more room and more attention to projects that change a lot.
Do not resend complete entries if you have not changed them.

--
Dr. Janis 

RE: [Haskell-cafe] Functional dependencies and incoherent instances

2008-10-08 Thread Tobias Bexelius
Yeah, I realized that.

But heres where I would like the undecidable incoherent instances to kick in, 
i.e. as long as I haven't got any NumVec instances GHC should be able to choose 
only one of the Mult instances. Or do I have too much faith in the 
-fallow-incoherent-instances flag now? :/

I would like to be able to write something like
 instance (Vec a x, -Num (a x)) = Mult (a x) (a x) x where (*.) = dot
where -Num (a x) means that (a x) must not be an instance of Num. Can I express 
this in some way?

Regards
Tobias

-Original Message-
From: Joel Björnson [mailto:[EMAIL PROTECTED] 
Sent: den 8 oktober 2008 15:50
To: Tobias Bexelius
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Functional dependencies and incoherent instances

Hi,

On Wed, Oct 8, 2008 at 2:31 PM, Tobias Bexelius [EMAIL PROTECTED] wrote:
 Hi,

 Im trying to overload a multiplication operator for scalars and 
 vectors, but keep running into the error message Functional 
 dependencies conflict. What I think is going on is that the 
 dependency check doesn't work with incoherent (or overlapping) 
 instances. In the example below, the two instances of Mult are 
 overlapping. What I want is the vector version to be used for vectors 
 and the scalar version used for numbers, even if a vector-type is an 
 instance of the Num-class (I believe -fallow-incoherent-instances 
 would make that kind of choise for me, right?).

 Im using the Visual Studio plugin Visual Haskell, and thus GHC version 
 6.6. Otherwise I think associated types might have worked better for 
 this...


 {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances 
 -fallow-incoherent-instances #-}

 data V2 a = V2 a a

 class Vec v a where
dot :: v a - v a - a
 instance Num a = Vec V2 a where
V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2

 class Mult a b c | a b - c where
(*.) :: a - b - c
 instance (Num x) = Mult x x x where (*.) = (*) instance (Vec a x) = 
 Mult (a x) (a x) x where (*.) = dot

According to the definition of Mult the parameter 'c' from above should be 
uniquely determined by a pair of types 'a' and 'b'. Now, lets say we have a 
type NumVec that instantiates both the Vec class and the Num as in

instance Num (NumVec a) where
instance Vec NumVec a where

Then according to the instance declaration

instance (Num x) = Mult x x x where ...

(NumVec a)  (NumVec a) (NumVec a) instantiates the class. On the other hand 
looking at the instance declaration:

instance (Vec a x) = Mult (a x) (a x) x where ...

(NumVec a) (NumVec a)  a , is also an instance why the fun dep (a b -
c) is violated.

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


[Haskell-cafe] Simple Table Update

2008-10-08 Thread Paul Keir
Hi,

I'd like to create a new list based on an original list, using information from 
a second (symbol) list. That second list should be updated as each element in 
the new list is added. I've been using map a lot, but that's not an option 
here, and I'm having trouble obtaining a good recursive structure for my 
function.

The minimal fixpus function below shows the problem. I have sts on both 
sides of the : list construct, but I'd like the second sts to be a version 
modified by the where (singular) function, fixpu.

fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
fixpus []   _  = []
fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts

  where fixpu pu sts = pu

(Below) I tried making fixpu return a tuple, and then use fst, snd and 
let, but I think it looks strange. I know it's quite basic, but I'd like a 
strong foundation for what's likely to become a medium-scale project. Can 
anyone offer advice?

fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
fixpus []   _  = []
fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a)

  where fixpu pu sts = (pu,sts ++ [(,[])])

Regards,
Paul

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


Re: [Haskell-cafe] monadic parser with Happy and Alex

2008-10-08 Thread Manlio Perillo

Timothy Goddard ha scritto:

On Sun, 05 Oct 2008 04:05:51 Manlio Perillo wrote:

Hi.

I have completed a draft of a CSS lexer, using Alex.
http://hg.mperillo.ath.cx/haskell/webtools/file/tip/src/CSS/Lexer.x

The lexer use the posn wrapper.

Now I'm starting to write the parser with Happy, however for the final
product I would like to:
1) Be able to do I/O in the lexer, for stylesheets inclusion
(@import rule)
2) be able to keep state in the parser (or lexer?), for character
transcoding (@charset rule)


This should be possible with Happy (and there are some example), however
  I don't find examples that make use of a lexer written with Alex.

Should I write a lexer using only the Alex basic interface (without
wrappers)?



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


Hi Manlio,

You may be better off separating the parsing from the import process. You 
would first parse it in to internal data structures (including an option for 
import) then go through that and replace import statements with the parsed 
content of those files. 


Thanks, this seems the best solution.

Producing a list which is then consumed by an IO 
procedure is almost exactly equivalent to threading IO through the entire 
parser and is a lot tidier, more flexible and should be easier to maintain.





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


Re: [Haskell-cafe] OT: Haskell desktop wallpaper?

2008-10-08 Thread Brandon S. Allbery KF8NH

On Oct 8, 2008, at 05:12 , Magnus Therning wrote:

This morning I got tired of my desktop wallpaper (one that ships with
Debian's Gnome packages).  Typing haskell desktop wallpaper yeilded
a lot of links to wallpapers with Colleen Haskell, while she's a
beautiful lady it wasn't exactly what I was hoping to find.  Hence
this email.  Where can I find some nice wallpapers inspired by
Haskell, or maybe even created by Haskell code?



Haskell-created:

http://www.frank-buss.de/haskell/OlympicRings.hs.txt
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/nymphaea

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


[Haskell-cafe] Re: [hmatrix] build error

2008-10-08 Thread Alberto Ruiz

Hi Xiao-Yong,

In i686 Arch linux, with the normal blas and lapack, I need:

extra-libraries: gsl lapack blas gslcblas gfortran

But using atlas-lapack:

extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s

I don't know how I found that __powidf2 is in libgcc_s  :)

I will add these options to hmatrix.cabal.

-Alberto



Xiao-Yong Jin wrote:

Hi, looks like I hit a bug, but I'm not sure which software
it belongs to, gcc, ghc or atlas?

-- error doing runhaskell Setup build --
Preprocessing library hmatrix-0.4.1.0...
/usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol 
`__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) 
isreferenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed
command was: /usr/bin/ghc -optl-lgsl -optl-llapack 
dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o 
dist/build/Numeric/GSL/Special/Internal_hsc_make
-- error doing runhaskell Setup build --

I believe `__powidf2' is a internal symbol in gcc and it is
hidden.

The system is archlinux x86_64 and the software I used are

atlas-lapack 3.8.2-1

gcc 4.3.2-1
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix 
--mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit 
--disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu 
--disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.3.2 (GCC)

ghc 6.8.2-2
 [(Project name,The Glorious Glasgow Haskell Compilation System)
 ,(Project version,6.8.2)
 ,(Booter version,6.8.2)
 ,(Stage,2)
 ,(Interface file version,6)
 ,(Have interpreter,YES)
 ,(Object splitting,YES)
 ,(Have native code generator,YES)
 ,(Support SMP,YES)
 ,(Unregisterised,NO)
 ,(Tables next to code,YES)
 ,(Win32 DLLs,)
 ,(RTS ways, debug  thr thr_p thr_debug)
 ,(Leading underscore,NO)
 ]

I googled but no useful information.

Best,
Xiao-Yong

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


Re: [Haskell-cafe] Functional dependencies and incoherent instances

2008-10-08 Thread Ryan Ingram
On Wed, Oct 8, 2008 at 2:59 PM, Tobias Bexelius
[EMAIL PROTECTED] wrote:
 Or do I have too much faith in the -fallow-incoherent-instances flag now? :/

Overlapping instances are an instance definition-time feature;
incoherent instances only become applicable at the call site for
polymorphic functions in the presence of overlapping instances.

As an example, consider the following overlapping instances:

{-# LANGUAGE OverlappingInstances #-}

class Foo a where foo :: a - Bool

instance Foo a where
  foo x = False

instance Foo Integer where
  foo x = (x == 3)

test1 :: String - Bool
test1 x = foo x  -- uses Foo a instance

test2 :: Integer - Bool
test2 x = foo x -- uses Foo Integer instance

test3 :: a - Bool
test3 x = foo x -- incoherent!

Consider (test3 (3 :: Integer)).  This should definitely use the
implementation for instance Foo Integer.  But it can't, because test3
doesn't know what type its argument is!

Incoherent instances still allows test3 to compile, but it may choose
the wrong instance.  In this case, test3 will use the Foo a
instance no matter what type of argument you pass it.

But the incoherency only arises at a call-site for the class method;
if you take test3 out of this program, the instances are still
overlapping but there is no compile problem (assuming
-foverlapping-instances).  If you are getting an error because of an
instance definition, as opposed to a call site, incoherent instances
won't help you.

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


Re: [Haskell-cafe] Simple Table Update

2008-10-08 Thread Ryan Ingram
Prelude :t Data.List.mapAccumL
Data.List.mapAccumL :: (acc - x - (acc, y)) - acc - [x] - (acc, [y])

I'm sure you can fill in the details :)

  -- ryan

2008/10/8 Paul Keir [EMAIL PROTECTED]:
 Hi,

 I'd like to create a new list based on an original list, using information
 from a second (symbol) list. That second list should be updated as each
 element in the new list is added. I've been using map a lot, but that's not
 an option here, and I'm having trouble obtaining a good recursive structure
 for my function.

 The minimal fixpus function below shows the problem. I have sts on both
 sides of the : list construct, but I'd like the second sts to be a
 version modified by the where (singular) function, fixpu.

 fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
 fixpus []   _  = []
 fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts

   where fixpu pu sts = pu

 (Below) I tried making fixpu return a tuple, and then use fst, snd and
 let, but I think it looks strange. I know it's quite basic, but I'd like a
 strong foundation for what's likely to become a medium-scale project. Can
 anyone offer advice?

 fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
 fixpus []   _  = []
 fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a)

   where fixpu pu sts = (pu,sts ++ [(,[])])

 Regards,
 Paul


 ___
 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] Functional dependencies and incoherent instances

2008-10-08 Thread Emil Axelsson

I think the technique described at

  http://haskell.org/haskellwiki/GHC/AdvancedOverlap

may give you what you want. I've never tried it myself though.

/ Emil



Tobias Bexelius skrev:

Yeah, I realized that.

But heres where I would like the undecidable incoherent instances to kick in, 
i.e. as long as I haven't got any NumVec instances GHC should be able to choose 
only one of the Mult instances. Or do I have too much faith in the 
-fallow-incoherent-instances flag now? :/

I would like to be able to write something like

instance (Vec a x, -Num (a x)) = Mult (a x) (a x) x where (*.) = dot

where -Num (a x) means that (a x) must not be an instance of Num. Can I express 
this in some way?

Regards
Tobias


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


[Haskell-cafe] Re: [Haskell] Catching error / making library functions monadic (in failure)

2008-10-08 Thread Duncan Coutts
On Wed, 2008-10-08 at 18:07 +0200, Philip K.F. Hölzenspies wrote:

 I think this is the core problem I have. Really, error should be implemented 
 as fail, rather than vice versa. I see why this doesn't work, because it 
 would type
 
 error :: Monad m = String - m a
 
 even though the whole idea is that it's typed 'a'.

Right, that's exactly why it would not work to give error that type.

However error should only be being used for programming errors, not for
expected runtime errors.

 Nonetheless, I would like 
 it if either IO wasn't the only monad allowing catching, or standard 
 functions not only being available with 'error' stuff (like !!, head, etc.).

Those functions do have safe counterparts for when you cannot guarantee
the pre-condition. It typically involves pattern matching, eg instead of
head use:

case foo of
  [] -
  (x:xs) -

Or for !! you could use take or splitAt and pattern matching.

If you want more exact analogues of head, !! etc then see Neil's Safe
library.

  If you can report them we can fix them.
 
 I think I spoke too soon. The error occur in other libraries' functions, so I 
 unjustly smudged your wonderful gtk2hs work (for which, btw: thanks very, 
 very much).

ok :-)

 To be honest; when I write a library, I also don't assume monadic 
 contexts for stuff that I do in purely functional terms. Sometimes errors 
 occur only in deeply nested code and just putting in error is the easy way 
 out. Especially, libraries that are not intended for industrial strength 
 production code seem to be prone to this type of coding, when they're not 
 already monadic.

I think it's not as bad as you suggest. In haskell, error is like
unchecked exceptions or assertions in Java. They are for cases that
really indicate a programmer error, not for bad input or IO failures.
Even these kinds of errors can be caught and contained in a sensible way
using exception handlers in IO.

For example supposing some web server page handler had some programming
error and called a function in a way that violated the pre-condition and
called error. That need not kill the entire server. The page handler
just needs to catch all exceptions and return a 500 internal server
error and write the error out to the logs. So it's actually a reasonably
robust way of dealing with the inevitable programmer errors.

Duncan

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


[Haskell-cafe] Re: [hmatrix] build error

2008-10-08 Thread Xiao-Yong Jin
Alberto Ruiz [EMAIL PROTECTED] writes:

 Hi Xiao-Yong,

 In i686 Arch linux, with the normal blas and lapack, I need:

   extra-libraries: gsl lapack blas gslcblas gfortran

 But using atlas-lapack:

   extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s

I guess you want cblas instead of gslcblas, since atlas has
it.


 I don't know how I found that __powidf2 is in libgcc_s  :)


References and bibliography is truly important.

 I will add these options to hmatrix.cabal.

 -Alberto

Thanks a lot for the excellent work.

Xiao-Yong
-- 
c/*__o/*
\ * (__
*/\  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Simple Table Update

2008-10-08 Thread Paul Keir
It brings tears to my eyes to see such a beautiful function ;) You've hit the 
nail on the head Ryan. The new version of my second previous code snippet now 
no longer requires fixpu*, and is:

typeCheckAST (Program pus) = Program $ snd $ mapAccumL f [] pus

  where f st pu = (st ++ [(,[])],pu)

Many thanks,
Paul

-Original Message-
From: Ryan Ingram [mailto:[EMAIL PROTECTED]
Sent: Wed 08/10/2008 18:03
To: Paul Keir
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Simple Table Update
 
Prelude :t Data.List.mapAccumL
Data.List.mapAccumL :: (acc - x - (acc, y)) - acc - [x] - (acc, [y])

I'm sure you can fill in the details :)

  -- ryan

2008/10/8 Paul Keir [EMAIL PROTECTED]:
 Hi,

 I'd like to create a new list based on an original list, using information
 from a second (symbol) list. That second list should be updated as each
 element in the new list is added. I've been using map a lot, but that's not
 an option here, and I'm having trouble obtaining a good recursive structure
 for my function.

 The minimal fixpus function below shows the problem. I have sts on both
 sides of the : list construct, but I'd like the second sts to be a
 version modified by the where (singular) function, fixpu.

 fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
 fixpus []   _  = []
 fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts

   where fixpu pu sts = pu

 (Below) I tried making fixpu return a tuple, and then use fst, snd and
 let, but I think it looks strange. I know it's quite basic, but I'd like a
 strong foundation for what's likely to become a medium-scale project. Can
 anyone offer advice?

 fixpus :: [ProgUnit] - [ProgUnitSymbolTable] - [ProgUnit]
 fixpus []   _  = []
 fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a)

   where fixpu pu sts = (pu,sts ++ [(,[])])

 Regards,
 Paul


 ___
 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] OT: Haskell desktop wallpaper?

2008-10-08 Thread R . Emre Başar
Hi,

I created a wallpaper from The.Monad.Reader logo. You can find two
versions here:

http://tonguc.name/images/lambda-1280x800.png
http://tonguc.name/images/lambda-1024x768.png

Magnus Therning der ki:
 This morning I got tired of my desktop wallpaper (one that ships with
 Debian's Gnome packages).  Typing haskell desktop wallpaper yeilded
 a lot of links to wallpapers with Colleen Haskell, while she's a
 beautiful lady it wasn't exactly what I was hoping to find.  Hence
 this email.  Where can I find some nice wallpapers inspired by
 Haskell, or maybe even created by Haskell code?
 
 Oh yes, wallpapers related to XMonad would do, I suppose ;-)
 
 /M
 
 -- 
 Magnus Therning(OpenPGP: 0xAB4DFBA4)
 magnus@therning.org  Jabber: magnus@therning.org
 http://therning.org/magnus identi.ca|twitter: magthe

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


-- 
R. Emre Başar
İstanbul Bilgi University
Department of Computer Science


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


[Haskell-cafe] synchronous channels in STM

2008-10-08 Thread roger peppe
I was wondering if it was possible to implement synchronous channels
within STM. In particular, I'd like to have CSP-like send and recv primitives
on a channel that each block until the other side arrives to complete
the transaction.

I think I've convinced myself that it's not possible, but
anyone care to differ?

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


[Haskell-cafe] ghc 6.10 and parsec

2008-10-08 Thread Jason Dusek
  Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or
  Parsec 3?

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


Re: [Haskell-cafe] synchronous channels in STM

2008-10-08 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

roger peppe wrote:
 I was wondering if it was possible to implement synchronous channels
 within STM. In particular, I'd like to have CSP-like send and recv primitives
 on a channel that each block until the other side arrives to complete
 the transaction.
 
 I think I've convinced myself that it's not possible, but
 anyone care to differ?

This sounds similar to what I once tried for a FRP implementation. I
decided that what I was trying to do was impossible (at least without
recalculating things all the time whenever something retries), and then
constructed an IVar implementation which was working very elegantly
(before I decided to change the core ideas behind my FRP implementation).

As luck would have it, Luke Palmer recently added his own IVar
implementation to Hackage, which you may find a use for.

- - Jake
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjtMQwACgkQye5hVyvIUKk39QCcDdsFY7z0k2xwkJ/zBK3tVsbT
n28An2D9LzUfWiWTpKIU7J7tt/VGs4EB
=kQGz
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3

2008-10-08 Thread Ivan Miljenovic
2008/10/8 Gwern Branwen [EMAIL PROTECTED]:

 So it'll be fixed for the next release? Cool then; I look forward to seeing 
 my XMC modules' analysis.


Yeah, I was planning on making a new release some time this week...
and then I somehow accidentally uninstalled just about everything on
my system, and have to do a reinstall :s

-- 
Ivan Lazar Miljenovic
[EMAIL PROTECTED]
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc 6.10 and parsec

2008-10-08 Thread Paulo Tanimoto
Jason,

If this is representative of what it will be, here's what I have:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.0.20081007

$ ghc-pkg list parsec
/usr/local/lib/ghc-6.10.0.20081007/./package.conf:
parsec-2.1.0.1


Paulo


On Wed, Oct 8, 2008 at 5:14 PM, Jason Dusek [EMAIL PROTECTED] wrote:
  Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or
  Parsec 3?

 --
 _jsn
 ___
 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] Hoogle? [Stacking monads]

2008-10-08 Thread Reiner Pope
The syntax is for the implicit parameter extension[1]. I think you would
write your example as

foo (undefined :: Bar x) ?z :: Bar y

Then querying the type of that whole expression with :t will list ?z's type
in the expression's constraints. (Of course, you should turn off the
monomorphism restriction so that ghc doesn't complain if constraints aren't
resolved).

[1]:
http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#implicit-parameters

Reiner



On Thu, Oct 9, 2008 at 6:11 AM, Andrew Coppin
[EMAIL PROTECTED]wrote:

 Ryan Ingram wrote:



 There is such a tool, it's called ghci :)
 It just takes a bit of massaging to do what you want:

 ghci :set -fglasgow-exts
 ghci :t (?f some_func [?a .. ?b])

 Here's an example:
 Prelude :t ?f map [?a .. ?b]
 ?f map [?a .. ?b] :: forall t a b t1.
 (Enum t1,
?b::t1,
?a::t1,
?f::((a - b) - [a] - [b]) - [t1] - t)
 = t

 This tells you the types the variables have to have, and the type of
 the expression.

 Judicious use of (undefined :: type_signature) can also help.



 Using undefined is already a standard technique for me. But what it doesn't
 let you do is

  foo (undefined :: Bar x) (undefined) :: Bar y   -- What type is the second
 argument?

 I'm curios as to how the example you give actually works - I don't
 recognise that syntax at all...


 ___
 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] synchronous channels in STM

2008-10-08 Thread Claus Reinke

I was wondering if it was possible to implement synchronous channels
within STM. In particular, I'd like to have CSP-like send and recv primitives
on a channel that each block until the other side arrives to complete
the transaction.


Assuming that retry blocks until something changes, you could associate
a channel with a thread that encapsulates the transaction. Somewhat like this?

import Control.Concurrent.STM
import Control.Concurrent

sender write confirm = do
 atomically $ putTMVar write hi
 atomically $ takeTMVar confirm
 putStrLn sender done
 
receiver read = do

 r - atomically $ takeTMVar read
 putStrLn $ receiver done: ++r

channel read write confirm = atomically $ do
 w - takeTMVar write
 putTMVar read w
 putTMVar confirm ()

main = do 
 (read,write,confirm) - atomically $ do

   read - newEmptyTMVar
   write - newEmptyTMVar
   confirm - newEmptyTMVar
   return (read,write,confirm)
 forkIO (channel read write confirm)
 forkIO (threadDelay 300  receiver read)
 threadDelay 500  sender write confirm

You might also be interested in 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/chp


Claus


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


Re: [Haskell-cafe] ghc 6.10 and parsec

2008-10-08 Thread Jason Dusek
  Aye, I have that as well, but you never know :)

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


Re: [Haskell-cafe] ghc 6.10 and parsec

2008-10-08 Thread agentzh
On Thu, Oct 9, 2008 at 6:14 AM, Jason Dusek [EMAIL PROTECTED] wrote:
  Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or
  Parsec 3?


I do hope it will be 2. Parsec 3 is significantly slower than 2 in my
SQL parser.

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


Re: [Haskell-cafe] parsec 3 parsec 2

2008-10-08 Thread wman
Shouldn't hiding the package stop it from causing possible mayhem, yet it be
accessible to those packages depending on the new version explicitly ?

On Thu, Oct 9, 2008 at 2:53 AM, Jason Dusek [EMAIL PROTECTED] wrote:

  I recently took a look at the new Yi, and it looks neat but I
  am hesitant to install it -- it require Parsec 3. What will
  happen to my system, carefully maintained, if I unleash this
  new Parsec on my programs and the programs of others?

  Can I expect total breakage, coexistence or...?

 --
 _jsn
 ___
 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] synchronous channels in STM

2008-10-08 Thread Andrea Vezzosi
2008/10/9 Claus Reinke [EMAIL PROTECTED]

 I was wondering if it was possible to implement synchronous channels
 within STM. In particular, I'd like to have CSP-like send and recv
 primitives
 on a channel that each block until the other side arrives to complete
 the transaction.


 Assuming that retry blocks until something changes, you could associate
 a channel with a thread that encapsulates the transaction. Somewhat like
 this?


You don't need an additional channel thread:

module SyncChan (SyncChan, send, recv, newSyncChan) where

import Control.Concurrent.STM
import Control.Monad
import Control.Concurrent

newtype SyncChan a = SC { unSC :: TVar (State a) }

data State a = Ready | Sent a | Received

newSyncChan :: STM (SyncChan a)
newSyncChan = SC `fmap` newTVar Ready

send :: SyncChan a - a - IO ()
send (SC chan) x = do
atomically $ unsafeSend chan x
atomically $ waitReceiver chan

recv :: SyncChan a - STM a
recv (SC chan) = do
  s - readTVar chan
  case s of
Sent s - writeTVar chan Received  return s
_ - retry

unsafeSend chan x = do
  s - readTVar chan
  case s of
Ready - writeTVar chan (Sent x)
_- retry

waitReceiver chan = do
  s - readTVar chan
  case s of
Received - writeTVar chan Ready
_- retry

x | f = fmap f x

test b = do
  (x,y) - atomically $ liftM2 (,) newSyncChan newSyncChan
  forkIO $ join $ atomically $ -- since recv is in STM you can wait on
multiple channels at the same time
 (recv x | print)
 `mplus`
 (recv y | print)
  if b
 then send x 'a'
 else send y 1

as a bonus you can also try to send to the first available among multiple
channels:
(this formulation uses ExistentialQuantification but it's just a
convenience)

data Sending a = forall b. Sending (SyncChan b) b a

sendMulti :: [Sending a] - IO a
sendMulti [] = fail empty
sendMulti xs = do (m,r) - atomically $ msum $ map sending xs
  atomically m
  return r

sending :: Sending t - STM (STM (), t)
sending (Sending (SC chan) x k) = do
  unsafeSend chan x
  return (waitReceiver chan,k)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parsec 3 parsec 2

2008-10-08 Thread Jason Dusek
  I don't know anything about how to do that. Is this a Cabal
  thing? A GHC package registration thing?

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


Re: [Haskell-cafe] parsec 3 parsec 2

2008-10-08 Thread Alfonso Acosta
ghc-pkg hide {pkg-id}


On Thu, Oct 9, 2008 at 5:53 AM, Jason Dusek [EMAIL PROTECTED] wrote:
  I don't know anything about how to do that. Is this a Cabal
  thing? A GHC package registration thing?

 --
 _jsn
 ___
 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] Simplifying a IsFunction type class using type equality constraints

2008-10-08 Thread Manuel M T Chakravarty

Corey O'Connor:
I recently had a need to use the IsFunction typeclass described by  
Oleg here:

http://okmij.org/ftp/Haskell/isFunction.lhs

and am wondering if the use of the TypeCast class can be correctly
replaced by a type equality constraint.

The IsFunction and TypeCast classes were defined as:

data HTrue
data HFalse

class IsFunction a b | a - b
instance TypeCast f HTrue = IsFunction (x-y) f
instance TypeCast f HFalse = IsFunction a f

-- literally lifted from the HList library
class TypeCast   a b   | a - b, b-a   where typeCast   :: a - b
class TypeCast'  t a b | t a - b, t b - a where typeCast'  :: t- 
a-b
class TypeCast'' t a b | t a - b, t b - a where typeCast'' :: t- 
a-b
instance TypeCast'  () a b = TypeCast a b where typeCast x =  
typeCast' () x
instance TypeCast'' t a b = TypeCast' t a b where typeCast' =  
typeCast''

instance TypeCast'' () a a where typeCast'' _ x  = x


I found the use of TypeCast in the IsFunction could be replaced by a
type family:


class IsFunction a b | a - b
instance (f ~ TTrue) = IsFunction (x-y) f
instance (f ~ TFalse) = IsFunction a f


Yes, that's a fine way of simplifying the definition.  In fact, you  
should also be able to drop the functional dependency in the  
IsFunction class.


Manuel

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