Re: [Haskell-cafe] Re: Interesting feature

2008-07-07 Thread David Overton
On 08/07/2008, Benjamin L. Russell <[EMAIL PROTECTED]> wrote:
>  If you are interested in logic programming in a language with some
>  similarity to Haskell, you might also wish to investigate the strongly
>  typed logic programming language Godel (see
>  http://www.cs.bris.ac.uk/~bowers/goedel.html).  When I first saw an
>  example of the code, I was surprised that, unlike Prolog, the language
>  was strongly typed, and supported modules, and (albeit very loosely)
>  resembled Haskell, except that it was a logic programming language.

While we're plugging logic programming languages, you might also be interested
in Mercury (http://www.cs.mu.oz.au/research/mercury/).  This is a
logic/functional language with Prolog-like syntax, but with a Haskell-like
type system, including Hindley-Milner types and type classes.
IMHO Mercury is even closer to Haskell than Goedel.

Also, see my recent attempts at (constraint) logic programming in Haskell:
http://overtond.blogspot.com/2008/07/pre.html
http://overtond.blogspot.com/2008/07/haskell-sudoku-solver-using-finite.html

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


[Haskell-cafe] Swapping Monads

2008-07-07 Thread Dominic Steinitz
I have a solution so this is for interest only.

It is not normally the case that two monads compose to give another
monad. Monad transformers capture when this is possible. However, when
there is a "swap" function satisfying some commutative diagrams then it
can be proved that the monads compose  to produce a monad.

Is there such a swap function in a library? I had a look in the
comprehensive category-extra package but couldn't find anything.

Here's two possible implementations. Big caveat: I haven't proved that
these satisfy the commutative diagrams but I am confident that they will.

Option 1 define

swap :: (Functor m, Monad m) => Either String (m a) -> m (Either String a)
swap (Left s) = return (Left s)
swap (Right x) = fmap Right x

Option 2 use Traversable (EvilTerran's suggestion)

instance F.Foldable (Either String) where
   foldMap f (Left s)  = mempty
   foldMap f (Right x) = f x

instance T.Traversable (Either String) where
   traverse f (Left s)  = pure (Left s)
   traverse f (Right x) = Right <$> f x

and now you can use T.sequence to swap the monads around.

For further information see Composing Monads by Mark Jones and Luc
Duponcheel and Toposes, Triples and Theories by Barr & Wells (Section 9.2).

Dominic.




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


[Haskell-cafe] more database issues

2008-07-07 Thread Galchin, Vasili
[EMAIL PROTECTED]:~/Desktop/hsql-1.7$ runhaskell Setup.lhs clean
cleaning...
[EMAIL PROTECTED]:~/Desktop/hsql-1.7$ runhaskell Setup.lhs configure --user
--prefix=$HOME
Configuring hsql-1.7...
Warning: No license-file field.
[EMAIL PROTECTED]:~/Desktop/hsql-1.7$ runhaskell Setup.lhs build
Preprocessing library hsql-1.7...
Building hsql-1.7...

Database/HSQL.hsc:66:7:
Could not find module `System.Time':
  it is a member of package old-time-1.0.0.0, which is hidden
[EMAIL PROTECTED]:~/Desktop/hsql-1.7$

I have a global ghc installation plus a local one off my user directory. In
any case, when I do "ghc-pkg list"  old-time-1.0.0.0 is not hidden.

Bottom line is how do I install DB libraries with least pain??

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


Re: [Haskell-cafe] Portland & OSCon

2008-07-07 Thread wren ng thornton

John Goerzen wrote:

Hi,

OSCon is happening in Portland, OR starting 2 weeks from today, with
probably the largest number of people there on July 23 and 24.  I know
there are a number of Haskellers that live in the Portland area, and I
suspect a few more may be going to OSCon.

Anyone interested in a Haskell gathering someplace?

-- John


I'm no longer a local, alas, but you may also want to send a mail/post 
to the pdxfunc group: . I'm not 
sure how many of them on on here.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: A Monad for on-demand file generation?

2008-07-07 Thread Chung-chieh Shan
Joachim Breitner <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in 
gmane.comp.lang.haskell.cafe:
> Am Montag, den 30.06.2008, 07:08 -0500 schrieb Derek Elkins:
> > You may want to look at Magnus Carlsson's "Monads for Incremental
> > Computing" http://citeseer.comp.nus.edu.sg/619122.html
> not exactly what I need, but very interesting read. Maybe I can use some
> of the ideas.

You might also find relevant the work on "adaptive computation" by Umut
Acar and collaborators.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
2008-07-04  Independence from America!  http://caab.org.uk/
2008-07-05  International Co-operative Day  http://ica.coop/
http://www.guardian.co.uk/politics/2008/jul/02/labour.tradeunions

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


[Haskell-cafe] Re: type classes

2008-07-07 Thread Chung-chieh Shan
> class RingTy a b where
>   order :: a -> Integer
>   units :: a -> [b]

> class VectorSpaceTy a b | a - > b where
>   dimension :: a -> Integer
>   basis :: (Field c) => a -> [b c]
> 
> where `b' is a vector space over the field `c'.

It looks like you are using the first (of two) type arguments to the
RingTy and VectorSpaceTy type classes as abstract types; in other words,
operations on rings and vector spaces don't really care what the type
"a" is in "RingTy a b" and "VectorSpaceTy a b".  Is that true?

Assuming so, if I may strip away the (extremely sweet) syntactic sugar
afforded by type classes for a moment, what you seem to be doing is to
pass dictionaries of types

data RingTy a b = RingTy {
order :: a -> Integer,
units :: a -> [b] }

data VectorSpaceTy a b = VectorSpaceTy {
dimension :: a -> Integer,
basis :: forall c. (Field c) => a -> [b c] }

to operations on rings and vector spaces.  Because the type "a" is
abstract, you may as well pass dictionaries of types

data RingTy b = RingTy {
order :: Integer,
units :: [b] }

data VectorSpaceTy b = VectorSpaceTy {
dimension :: Integer,
basis :: forall c. (Field c) => [b c] }

to these operations.  The information that you want computed just
once per ring or per vector space can be defined as lexically scoped
variables where you create these dictionaries in the first place.

To add back the syntactic sugar (i.e., to make the dictionary arguments
implicit) and to make the type system check that elements of different
vector spaces are not confused, you may find Dylan Thurston's technique
useful: http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
2008-07-04  Independence from America!  http://caab.org.uk/
2008-07-05  International Co-operative Day  http://ica.coop/
http://www.guardian.co.uk/politics/2008/jul/02/labour.tradeunions

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


[Haskell-cafe] Re: Interesting feature

2008-07-07 Thread Benjamin L . Russell
On Mon, 7 Jul 2008 02:57:25 -0700 (PDT), fero
<[EMAIL PROTECTED]> wrote:

If you are interested in logic programming in a language with some
similarity to Haskell, you might also wish to investigate the strongly
typed logic programming language Godel (see
http://www.cs.bris.ac.uk/~bowers/goedel.html).  When I first saw an
example of the code, I was surprised that, unlike Prolog, the language
was strongly typed, and supported modules, and (albeit very loosely)
resembled Haskell, except that it was a logic programming language.

Here is an example of a program in Godel to compute a greatest common
divisor (note the strong typing and usage of a module system) (see
http://www.cs.bris.ac.uk/~bowers/goedel-example.html):

MODULE  GCD.

IMPORT  Integers.

PREDICATE   Gcd : Integer * Integer * Integer.

Gcd(i,j,d) <-
CommonDivisor(i,j,d) &
~ SOME [e] (CommonDivisor(i,j,e) & e > d).

PREDICATE   CommonDivisor : Integer * Integer * Integer.

CommonDivisor(i,j,d) <-
IF (i = 0 \/ j = 0)
THEN
  d = Max(Abs(i),Abs(j))
ELSE
  1 =< d =< Min(Abs(i),Abs(j)) &
  i Mod d = 0 &
  j Mod d = 0.

According to the home page for the language, 

> Go"del is a declarative, general-purpose programming language in the family 
> of 
> logic programming languages. It is a strongly typed language, the type system 
> being based on many-sorted logic with parametric polymorphism. It has a 
> module system. Go"del supports infinite precision integers, infinite 
> precision 
> rationals, and also floating-point numbers. It can solve constraints over 
> finite 
> domains of integers and also linear rational constraints. It supports 
> processing 
> of finite sets. It also has a flexible computation rule and a pruning 
> operator 
> which generalises the commit of the concurrent logic programming languages. 
> Considerable emphasis is placed on Go"del's meta- logical facilities which 
> provide 
> significant support for meta-programs that do analysis, transformation, 
> compilation, verification, debugging, and so on.

-- Benjamin L. Russell

>Hi I have read in one tutorial (I can't find it again, but it was probably
>either one on ibm, gentle introduction or yaht), that it is possible to
>define relationships between free variables and the same program can be used
>to calculate either first variable when second is set or second when first
>is set. I have understood this as if I set first free variable, run program
>and write name of second variable and I get result, and vice versa. I don't
>know if I understood it well. It looks really interesting but I can't figure
>out how to do it. Is this really possible? (I doubt.) If yes show example
>please. 
>
>Thanks
>Fero

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


[Haskell-cafe] Hoogle often updates ?

2008-07-07 Thread L.Guo
Hi Haskellers:

I have just been asked for usage of timer in haskell. Which I did not
remember clearly. So I ask the search engine.

In Hoogle: timer
In Google: haskell timer

After I tried these, I wonder, when and how often the hoogle update its
database? And, could hoogle search range cover the hackages?

I like hoogle engine. Bcuz it is a very usful tool which helps me learn
haskell. Wish it better.

Regards
--
L.Guo
2008-07-08

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


Re: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation

2008-07-07 Thread Don Stewart
Just use 'rnf', from the Control.Parallel namespace.

ryani.spam:
> This is the classic "exception embedded in pure value" problem with
> lazy languages.  There's no need for the "a" returned by "return" to
> be evaluated.
> 
> Even using "seq" isn't quite good enough:
> 
> > boom2 = [1 `div` 0]
> 
> ghci> doTinIO (boom2 `seq` return boom2)
> Right [*** Exception: divide by zero
> 
> If you want to guarantee that all embedded exceptions have been
> excised from a pure value, you need something like deepSeq; see
> http://hackage.haskell.org/packages/archive/hxt/7.4/doc/html/Control-Strategies-DeepSeq.html
> 
>   -- ryan
> 
> On 7/7/08, Tim Bauer <[EMAIL PROTECTED]> wrote:
> > The file below models a problem I have been trying to figure out.
> > This file simplifies my original code, while still illustrating
> > the problem.
> >
> > > import Prelude hiding (catch)
> > > import Control.Monad.Reader
> > > import Control.Monad.Error
> > > import Control.Exception
> > > import System.IO(readFile)
> > > import Data.Either(either)
> >
> >
> > Our monad transformer is an ErrorT which wraps the IO monad.
> > ErrorT allows us to use throwError, but we won't use it in this example.
> >
> > > type T a = ErrorT String IO a
> >
> > The following runs a (T a) in the context of the IO monad.
> > We wrap runErrorT in try so as to catch things like division
> > by zero and what not.
> >
> > > doTinIO :: T a -> IO (Either String a)
> > > doTinIO ta = do
> > >  exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a))
> > >  return $ case exesa  of
> > >Left  x   -> Left ("EX: "++(show x))
> > >Right esa -> esa
> > >
> > > boom = 1 `div` 0
> > > b1 = return boom :: T Int
> > > bad = doTinIO b1
> >
> > The above, bad, results in:
> >   Right *** Exception: divide by zero
> > My hope was to get
> >   Left "EX: divide by zero"
> >
> > I cannot understand why the `try' does not get a chance at the
> > erroneous calculation. That is, I want the try to catch
> > the runtime exception.
> >
> > Indeed, if the IO computation is strictly computed, I  get
> > the proper result.
> >
> > > g1 = boom `seq` (return boom :: T Int)
> > > good = doTinIO g1
> >
> > Stuff that raises exceptions in IO actions does not work either.
> >
> > > g2 = doTinIO (return boom)
> >
> > Results in: ``Right *** Exception: divide by zero''
> > However, other actions that do raise errors work correctly.
> >
> > It appears the value of the computation must be used
> > as the next two examples show.
> >
> > > g3 = doTinIO (liftIO (readFile "nonexistent"))
> > > g4 = doTinIO (liftIO (print boom))
> >
> > My problem is that I control `doTinIO', but someone else provides
> > the computation (T a). I cannot force callers to strictly evaluate
> > their computations.
> >
> > I've tried three other variants (given below) that are all
> > nearly equivalent.
> >
> > > handler :: Exception -> IO (Either String a)
> > > handler = return . Left . ("EX: "++) . show
> > >
> > > doTinIO2 :: T a -> IO (Either String a)
> > > doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler
> > >
> > > doTinIO3 :: T a -> IO (Either String a)
> > > doTinIO3 ta = do
> > >  esa <- catch (runErrorT ta) handler
> > >  case esa of
> > >Right a -> catch (evaluate (return a)) handler
> > >l -> return l
> > >
> > > doTinIO4 :: T a -> IO (Either String a)
> > > doTinIO4 ta = catch (runErrorT ta) handler
> >
> > *Main> doTinIO2 b1
> > Right *** Exception: divide by zero
> > *Main> doTinIO3 b1
> > Right *** Exception: divide by zero
> > *Main> doTinIO4 b1
> > Right *** Exception: divide by zero
> >
> > Any suggestions? Thanks 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Avoiding lazy evaluation in an ErrorT computation

2008-07-07 Thread Ryan Ingram
This is the classic "exception embedded in pure value" problem with
lazy languages.  There's no need for the "a" returned by "return" to
be evaluated.

Even using "seq" isn't quite good enough:

> boom2 = [1 `div` 0]

ghci> doTinIO (boom2 `seq` return boom2)
Right [*** Exception: divide by zero

If you want to guarantee that all embedded exceptions have been
excised from a pure value, you need something like deepSeq; see
http://hackage.haskell.org/packages/archive/hxt/7.4/doc/html/Control-Strategies-DeepSeq.html

  -- ryan

On 7/7/08, Tim Bauer <[EMAIL PROTECTED]> wrote:
> The file below models a problem I have been trying to figure out.
> This file simplifies my original code, while still illustrating
> the problem.
>
> > import Prelude hiding (catch)
> > import Control.Monad.Reader
> > import Control.Monad.Error
> > import Control.Exception
> > import System.IO(readFile)
> > import Data.Either(either)
>
>
> Our monad transformer is an ErrorT which wraps the IO monad.
> ErrorT allows us to use throwError, but we won't use it in this example.
>
> > type T a = ErrorT String IO a
>
> The following runs a (T a) in the context of the IO monad.
> We wrap runErrorT in try so as to catch things like division
> by zero and what not.
>
> > doTinIO :: T a -> IO (Either String a)
> > doTinIO ta = do
> >  exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a))
> >  return $ case exesa  of
> >Left  x   -> Left ("EX: "++(show x))
> >Right esa -> esa
> >
> > boom = 1 `div` 0
> > b1 = return boom :: T Int
> > bad = doTinIO b1
>
> The above, bad, results in:
>   Right *** Exception: divide by zero
> My hope was to get
>   Left "EX: divide by zero"
>
> I cannot understand why the `try' does not get a chance at the
> erroneous calculation. That is, I want the try to catch
> the runtime exception.
>
> Indeed, if the IO computation is strictly computed, I  get
> the proper result.
>
> > g1 = boom `seq` (return boom :: T Int)
> > good = doTinIO g1
>
> Stuff that raises exceptions in IO actions does not work either.
>
> > g2 = doTinIO (return boom)
>
> Results in: ``Right *** Exception: divide by zero''
> However, other actions that do raise errors work correctly.
>
> It appears the value of the computation must be used
> as the next two examples show.
>
> > g3 = doTinIO (liftIO (readFile "nonexistent"))
> > g4 = doTinIO (liftIO (print boom))
>
> My problem is that I control `doTinIO', but someone else provides
> the computation (T a). I cannot force callers to strictly evaluate
> their computations.
>
> I've tried three other variants (given below) that are all
> nearly equivalent.
>
> > handler :: Exception -> IO (Either String a)
> > handler = return . Left . ("EX: "++) . show
> >
> > doTinIO2 :: T a -> IO (Either String a)
> > doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler
> >
> > doTinIO3 :: T a -> IO (Either String a)
> > doTinIO3 ta = do
> >  esa <- catch (runErrorT ta) handler
> >  case esa of
> >Right a -> catch (evaluate (return a)) handler
> >l -> return l
> >
> > doTinIO4 :: T a -> IO (Either String a)
> > doTinIO4 ta = catch (runErrorT ta) handler
>
> *Main> doTinIO2 b1
> Right *** Exception: divide by zero
> *Main> doTinIO3 b1
> Right *** Exception: divide by zero
> *Main> doTinIO4 b1
> Right *** Exception: divide by zero
>
> Any suggestions? Thanks 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] extensible data types in Haskell?

2008-07-07 Thread Ryan Ingram
I like the approach the "Data Types a la Carte" paper takes to solve
this problem.

There's a small discussion here:
http://wadler.blogspot.com/2008/02/data-types-la-carte.html

Summary: if you model your data types as functors, typeclass machinery
lets you combine them into an extensible whole, while maintaining type
safety.  You then create an "interpretation" class which allows data
to choose how it interacts with a particular computation.

The biggest weakness is that you need a type annotation at the point
of calling the "interpretation" function.  An example (leaving out the
"library" bits):

class Functor a => EvalSimple a where
evalSimple :: a Int -> Int
instance (EvalSimple a, EvalSimple b) => EvalSimple (a :+: b) where
evalSimple (Inl a) = evalSimple a
evalSimple (Inr b) = evalSimple b

-- foldExpr :: Functor e => (e a -> a) -> Expr e -> a
-- eval :: EvalSimple e => Expr e -> Int
eval e = foldExpr evalSimple e

newtype Val a = Val Int -- "trivial" functor
instance Functor Val where fmap _ (Val x) = (Val x)
instance EvalSimple Val where evalSimple (Val x) = x
val x = inject (Val x)
-- inject :: a :<: e => a (Expr e) -> Expr e
-- val :: Val :<: e => Int -> Expr e


data Add a = Add a a -- "pair" functor
instance Functor Add where fmap f (Add a b) = Add (f a) (f b)
add a b = inject (Add a b)
instance EvalSimple Add where evalSimple (Add a b) = a + b

-- here is where we need the type annotation
sample :: Expr (Val :+: Add)
sample = add (add (val 1) (val 2)) (val 3)

sampleResult = eval sample  -- is 6

On 7/6/08, David Walker <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> SML conveniently contains the type "exn" which is an instance of an
> "extensible data type".  In other words, unlike normal data types that
> are "closed" (can't admit new constructors once defined), SML's exn
> type is "open," allowing programmers to keep adding new alternatives
> as often as they choose.  Like normal datatypes, the elimination form
> for an extensible data type is a case statement (or match function).
>
> Friends have told me that Haskell doesn't have extensible data types.
> However, it seems fairly straightforward to code them up using type
> classesthough the solution I'm thinking of has a little bit of
> boilerplate I'd like to scrap (you have to define a new type
> declaration *and* an instance of a type class with a "match" method)
> and matching occurs through a string comparison (which can lead to
> silly programmer errors if there is accidentally a typo in the
> string).
>
> Anyway, it's possible with some thought I could come up with a better
> solution, but before worrying about it, I figured I'd ask if anybody
> else already has a package that does this.  It seems like a pretty
> natural feature to want to have.
>
> Thanks in advance,
> Dave
> ___
> 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] Portland & OSCon

2008-07-07 Thread John Goerzen
Trevor Elliott wrote:
> Hi John,
> 
> I'd certainly be interested in some sort of meeting.  What did you have
> in mind?

I don't really know.  I'm not from Portland, so I'm sort of hoping that
one of you local folks could take the lead on that.  It could be a bar,
restaurant, park (insert obligatory xkcd references here), BoF at OSCon
(I think those are open to the public), or whatever everyone seems to like.

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


Re: [Haskell-cafe] Portland & OSCon

2008-07-07 Thread Trevor Elliott
Hi John,

I'd certainly be interested in some sort of meeting.  What did you have
in mind?

--trevor

On Mon, 2008-07-07 at 14:18 -0500, John Goerzen wrote:
> Hi,
>  
> OSCon is happening in Portland, OR starting 2 weeks from today, with
> probably the largest number of people there on July 23 and 24.  I know
> there are a number of Haskellers that live in the Portland area, and I
> suspect a few more may be going to OSCon.
> 
> Anyone interested in a Haskell gathering someplace?
> 
> -- John
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Portland & OSCon

2008-07-07 Thread John Goerzen
Hi,

OSCon is happening in Portland, OR starting 2 weeks from today, with
probably the largest number of people there on July 23 and 24.  I know
there are a number of Haskellers that live in the Portland area, and I
suspect a few more may be going to OSCon.

Anyone interested in a Haskell gathering someplace?

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


Re: [Haskell-cafe] parsec linking problem

2008-07-07 Thread naruto canada
On 7/7/08, Claude Heiland-Allen <[EMAIL PROTECTED]> wrote:
> naruto canada wrote:
>> I run into linking error with parsec:
>
>> ghc -o /tmp/a.out accu.hs
>
> Try ghc --make, or pass appropriate package flags on the command line so
> that it gets linked with Parsec.

Thanks, it works.

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


[Haskell-cafe] Re: [Gtk2hs-users] ANN: Gtk2Hs 0.9.13 released

2008-07-07 Thread Peter Gavin

Peter Hercek wrote:

Thanks for the package.
I experienced some bugs with it on windows. When showing a dynamically
  built context menu, I'm getting errors like these:

_cairo_win32_surface_show_glyphs(ExtTextOutW failed): The operation completed 
successfully.
_flush_glyphs: The operation completed successfully.

... and the text of some menu items is not shown (otherwise the menu
  items do work - actions are called when they are clicked).

When I try to run the app under ghci I get error like this:

Loading package glib-0.9.13 ... : Unknown PEi386 section name 
`.reloc' (while processing:
C:/tools/Gtk2Hs/HSglib.o)
ghc.exe: panic! (the 'impossible' happened)
   (GHC version 6.8.3 for i386-unknown-mingw32):
 loadObj: failed
Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Using older Gtk (2.10.13) helps for the first one.
Using my own compile of Gtk2Hs (I compiled older version 0.9.12.1
  myself) helps for the second one.

Peter.


Hi Peter,

The first problem looks like a problem in cairo.  I'm pretty sure the 
functions named are cairo internal API, you may want to report a bug to 
their list.  I suppose it's possible those functions always print the 
error message (even on success), but behave correctly otherwise.


It looks like the second problem is a GHC bug, since there isn't 
anything special about our library (that I can think of) that might 
cause that to happen.


Pete



Peter Gavin wrote:

Hello everyone,

Gtk2Hs version 0.9.13 is now available. [1]

New features:

 * bindings for Gnome VFS and GStreamer
 * a new Gtk+ tutorial has been adapted by Hans van Thiel
 * cairo image stride support
 * many new demos
 * compiles with GHC 6.8.3
 * lots of bug fixes

This release has been tested on a variety of platforms with different 
versions of Gtk+ and GHC, so you should have no trouble compiling it if 
you're using an older version of Gtk+.


Note that the binaries for Win32 for this release are only provided for 
GHC 6.8.3 and Gtk+ 2.12.  As with older releases, all the C libraries 
needed are included in the installer, so you don't need to download 
anything else to get up an running.  I've also created zip files 
containing only the C libraries that can be used for redistribution. 
The sources for these binaries are available at [2]


Links:
[1] 
http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440

[2] http://ftp.gnome.org/pub/GNOME/sources/


--
Pete

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php




-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
___
Gtk2hs-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/gtk2hs-users


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


Re: [Haskell-cafe] parsec linking problem

2008-07-07 Thread Claude Heiland-Allen

naruto canada wrote:

I run into linking error with parsec:



ghc -o /tmp/a.out accu.hs


Try ghc --make, or pass appropriate package flags on the command line so 
that it gets linked with Parsec.



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


[Haskell-cafe] parsec linking problem

2008-07-07 Thread naruto canada
hi

I've just managed to get ghc-6.8.3 installed and tried to run an
example from 
"http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing";

I run into linking error with parsec:

Here is the code:

module Main where
import System.Environment
import Text.ParserCombinators.Parsec hiding (spaces)

symbol :: Parser Char
symbol = oneOf "!#$%&|*+-/:<=>[EMAIL PROTECTED]"

main :: IO ()
main = do
-- args <- getArgs
-- putStrLn ("Hello, " ++ (args!!0) ++ " " ++ (args!!1) )
-- putStrLn ( show( read(args!!0) + read(args!!1) ) )
putStrLn ( "give me a name:" )
name <- getLine
putStrLn ( name )


ghc -o /tmp/a.out accu.hs
accu.o: In function `so8_info':
: undefined reference to
`parseczm2zi1zi0zi1_TextziParserCombinatorsziParsecziChar_oneOf_closure'
accu.o: In function `spP_info':
: undefined reference to
`__stginit_parseczm2zi1zi0zi1_TextziParserCombinatorsziParsec_'
accu.o: In function `so8_closure':
: undefined reference to
`parseczm2zi1zi0zi1_TextziParserCombinatorsziParsecziChar_oneOf_closure'
collect2: ld returned 1 exit status

Thanks


my installation steps (just in case you need to know):
WGET_UNPACK http://ftp.gnu.org/gnu/readline/readline-4.3.tar.gz
./configure --prefix=/usr
make clean ; make || INTERVENTION
find . -name libhistory.so*
find . -name libreadline.so*
cp shlib/libhistory.so.4.3 /lib
cp shlib/libreadline.so.4.3 /lib
ln -sfvn libhistory.so.4.3 /lib/libhistory.so.4
ln -sfvn libreadline.so.4.3 /lib/libreadline.so.4

WGET_UNPACK 
http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-i386-unknown-linux.tar.bz2
cd ghc-6.8.2
autoreconf
./configure --prefix=/usr
make install
echo 'main = putStrLn "hello"' > t.hs
ghc t.hs
./a.out | grep hello || INTERVENTION
rm -rf /build/ghc-6.8.2

WGET_UNPACK http://haskell.org/ghc/dist/6.8.3/ghc-6.8.3-src-extralibs.tar.bz2
WGET_UNPACK http://haskell.org/ghc/dist/6.8.3/ghc-6.8.3-src.tar.bz2
cd ghc-6.8.3
autoreconf
./configure --prefix=/usr
make clean ; make || INTERVENTION
make || INTERVENTION
make install
echo 'main = putStrLn "hello"' > t.hs
ghc t.hs
./a.out | grep hello || INTERVENTION
ghc --version | grep 6.8.3 || INTERVENTION
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: Gtk2Hs 0.9.13 released

2008-07-07 Thread Peter Gavin

Ashley Yakeley wrote:

Peter Gavin wrote:

Gtk2Hs version 0.9.13 is now available. [1]

New features:

 * bindings for Gnome VFS and GStreamer


Is this bindings for the new GIO/GVFS stuff?


No, its for the old GnomeVFS binding.  I may get around to the binding 
the new one, unless someone else wants to do it :)




Is Gtk2Hs cabal-ised?


Not yet, but it's planned.  The things we need from cabal to do it 
aren't finished yet, and every .chs file needs to be rewritten to work 
with the real c2hs, rather than our hacked up version :)


Pete



-- Ashley

___
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] Is there anything manifestly stupid about this code?

2008-07-07 Thread Don Stewart
lrpalmer:
> On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers
> <[EMAIL PROTECTED]> wrote:
> > Thanks.  Here's a newb question: what does strictness really get me in this
> > code?
> 
> A bit of speed and memory improvements, I suspect.  The type
> (Double,Double) has three boxes, one for the tuple and one for each
> double.  The type Complex, which is defined as
> 
> data Complex a = !a :+ !a
> 
> has one box (after -funbox-strict-fields has done its work), the one
> for the type as a whole.  So it will end up using less memory, and
> there will be fewer jumps to evaluate one (a jump is made for each
> box).

On a good day the two Double components will be unpacked into registers
entirely. As here, a loop on Complex:

{-# OPTIONS -funbox-strict-fields #-}

module M where

data Complex = !Double :+ !Double

conjugate :: Complex -> Complex
conjugate (x:+y) =  x :+ (-y)

realPart :: Complex -> Double
realPart (x :+ _) =  x

go :: Complex -> Double
go n | realPart n > pi = realPart n
 | otherwise   = go (conjugate n)

Note that notionally Complex has 3 indirections, the Complex
constructor, and two for the Doubles. After optimisation
however, there's only unboxed doubles in registers left:

M.$wgo :: Double# -> Double# -> Double#
M.$wgo =
  \ (ww_sjT :: Double#) (ww1_sjU :: Double#) ->
  case >## ww_sjT 3.141592653589793 of wild_Xs {
  False -> M.$wgo ww_sjT (negateDouble# ww1_sjU);
  True -> ww_sjT


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


[Haskell-cafe] Re: Is there anything manifestly stupid about this code?

2008-07-07 Thread Aaron Denney
On 2008-07-07, Luke Palmer <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers
><[EMAIL PROTECTED]> wrote:
>> BTW, I only noticed the Complex type late.  I looked at it and noticed that
>> all I'd be using is the constructor and add.  Didn't seem worth the  change.
>
> You would also be using the multiply and magnitude functions!

Well, he should continue to use a custom "magnitude squared" function,
to save the square-rooting.

-- 
Aaron Denney
-><-

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


Re: [Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support

2008-07-07 Thread Claus Reinke

"rlwrap" adds readline support to everything.


Well, yes, see the GHCi wiki for how to augment 'rlwrap ghci' with
some basic completion support (filenames, flags, module names):

http://www.haskell.org/haskellwiki/GHC/GHCi#rlwrap_-_what_to_try_when_your_GHCi_was_compiled_without_readline.2Feditline

but is there a way to make rlwrap's completion context-sensitive?

As with bash's complete command, for instance, I'd like to be able
to tell rlwrap that :load wants filenames, while :module wants module
names, and :set wants settable things. If your ghci is readline/editline
enabled, you get quite specific support (or so I gather from the
source code..), while rlwrap seems to throw everything in one pot.

That said, rlwrap is still a good workaround,
Claus


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


[Haskell-cafe] Re: Anglo Haskell 2008

2008-07-07 Thread Matthew Sackman
On Tue, Jul 01, 2008 at 01:15:31PM +0100, Matthew Sackman wrote:
> Anglo Haskell is a gathering of all people Haskell-related from
> beginners, to seasoned hackers to academic giants. All and more are
> welcomed by large fuzzy green lambdas.
> 
> In contrast to the last two years which have been held at MSR Cambridge
> (UK), we're this year proposing to hold the event at Imperial College,
> London. London is probably easier to get to and from (though more
> tedious to get across) than Cambridge and we hope this will attract
> people who previously have not been able to get out to Cambridge.
> 
> The proposed dates are Friday the 8th and Saturday the 9th of August.
> 
> More details are available on the wikipage:
> http://www.haskell.org/haskellwiki/AngloHaskell/2008
> Please feel free to add to this page.

There have been no objections to holding Anglo Haskell at Imperial this
year and no objections about dates either. Thus we're now able to
confirm this will happen at Imperial on the 8th and 9th of August as
advertised.

Some people have signed up on the wiki page, please add your name if you
are able to come or are considering coming along. Also please make use
of the wiki page and #anglohaskell irc channel to arrange where to stay
overnight if necessary.

Finally, once again, if you'd like to give a talk then please add your
name to the list on the wiki page. We really do need both attendees and
speakers to make this event a success.

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


Re: [Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly

2008-07-07 Thread Alfonso Acosta
Hi Pablo,

On Mon, Jul 7, 2008 at 10:07 AM, Pablo Nogueira
<[EMAIL PROTECTED]> wrote:
> GHCi infers it has type (up to renaming):
>
> (From a1 (s (a1 x)) x,  Bifunctor s,  To  a2 (s (a2 y)) y) => (x -> y)
> -> a1 x -> a2 y
>
> But if I cut and paste the type into the code I get type errors:
>
>   Could not deduce (From a1 (s1 (a11 x)) x) ...
>Could not deduce (From a11 (s1 (a11 x)) x, To a21 (s1 (a21 y)) y) ...
>Could not deduce (From a1 (s1 (a11 x)) x) ...

I myselft  don't understand why GHCi doesn't accept the type it
infered as an explicit signature ... but your problem seems to be
caused by a lack of functional dependencies.

Redefining To and From as ..

class From a c x | a -> c where
from :: a x -> c x

class To a c y | c -> a where
to :: c y -> a y

... hushes GHCi. The question now is, of course, if the new
dependencies are too restrictive for your problem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenSSL.Digest linking error: EVP_mdc2

2008-07-07 Thread Ken Takusagawa
Thanks.  Here's the quick-and-dirty patch I applied to make things work.

--- /tmp/hopenssl-1.0/OpenSSL/Digest.hs 2008-02-20 18:43:43.0 -0500
+++ hopenssl-1.0/OpenSSL/Digest.hs  2008-07-07 02:06:55.0 -0400
@@ -197,7 +197,7 @@
 foreign import ccall unsafe "EVP_sha1"  mdSHA1  :: IO MDEngine
 foreign import ccall unsafe "EVP_dss"   mdDSS   :: IO MDEngine
 foreign import ccall unsafe "EVP_dss1"  mdDSS1  :: IO MDEngine
-foreign import ccall unsafe "EVP_mdc2"  mdMDC2  :: IO MDEngine
+--foreign import ccall unsafe "EVP_mdc2"  mdMDC2  :: IO MDEngine
 foreign import ccall unsafe "EVP_ripemd160" mdRIPEMD160 :: IO MDEngine

 -- |Map a 'MessageDigest' type into the the corresponding
@@ -211,7 +211,7 @@
 toMDEngine SHA1  = mdSHA1
 toMDEngine DSS   = mdDSS
 toMDEngine DSS1  = mdDSS1
-toMDEngine MDC2  = mdMDC2
+toMDEngine MDC2  = undefined
 toMDEngine RIPEMD160 = mdRIPEMD160

 -- * Helper Functions

On Mon, Jul 7, 2008 at 1:51 AM, Donn Cave <[EMAIL PROTECTED]> wrote:
> Quoth "Ken Takusagawa" <[EMAIL PROTECTED]>:
>
> | $ ghc --make test-hopenssl.hs  -lcrypto
> | [1 of 1] Compiling Main ( test-hopenssl.hs, test-hopenssl.o )
> | Linking test-hopenssl ...
> | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
> | function `s2O8_info':
> | (.text+0xf3a): undefined reference to `EVP_mdc2'
> | /tmp/ken/lib/hopenssl-1.0/ghc-6.8.2/libHShopenssl-1.0.a(Digest.o): In
> | function `s2TQ_info':
> | (.text+0x1435): undefined reference to `EVP_mdc2'
> | collect2: ld returned 1 exit status
>
> I see the following in the Configure file for openssl-0.9.8h:
>
>  my $default_depflags = "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS 
> -DOPENSSL_NO_GMP -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 
> -DOPENSSL_NO_SEED -DOPENSSL_NO_TLSEXT ";my $default_depflags = 
> "-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP
>
> I don't know why this would be, but I infer that the function hopenssl
> was looking for is commonly missing in SSL builds.
>
>Donn Cave, [EMAIL PROTECTED]
> ___
> 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] Avoiding lazy evaluation in an ErrorT computation

2008-07-07 Thread Brandon S. Allbery KF8NH


On 2008 Jul 7, at 11:14, Tim Bauer wrote:


My problem is that I control `doTinIO', but someone else provides
the computation (T a). I cannot force callers to strictly evaluate
their computations.



try (Control.Exception.evaluate ...) -- ?

--
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] Avoiding lazy evaluation in an ErrorT computation

2008-07-07 Thread Tim Bauer

The file below models a problem I have been trying to figure out.
This file simplifies my original code, while still illustrating
the problem.

> import Prelude hiding (catch)
> import Control.Monad.Reader
> import Control.Monad.Error
> import Control.Exception
> import System.IO(readFile)
> import Data.Either(either)


Our monad transformer is an ErrorT which wraps the IO monad.
ErrorT allows us to use throwError, but we won't use it in this example.

> type T a = ErrorT String IO a

The following runs a (T a) in the context of the IO monad.
We wrap runErrorT in try so as to catch things like division
by zero and what not.

> doTinIO :: T a -> IO (Either String a)
> doTinIO ta = do
>  exesa <- try (runErrorT ta) -- IO (Either Exception (Either String a))
>  return $ case exesa  of
>Left  x   -> Left ("EX: "++(show x))
>Right esa -> esa
>
> boom = 1 `div` 0
> b1 = return boom :: T Int
> bad = doTinIO b1

The above, bad, results in:
   Right *** Exception: divide by zero
My hope was to get
   Left "EX: divide by zero"

I cannot understand why the `try' does not get a chance at the
erroneous calculation. That is, I want the try to catch
the runtime exception.

Indeed, if the IO computation is strictly computed, I  get
the proper result.

> g1 = boom `seq` (return boom :: T Int)
> good = doTinIO g1

Stuff that raises exceptions in IO actions does not work either.

> g2 = doTinIO (return boom)

Results in: ``Right *** Exception: divide by zero''
However, other actions that do raise errors work correctly.

It appears the value of the computation must be used
as the next two examples show.

> g3 = doTinIO (liftIO (readFile "nonexistent"))
> g4 = doTinIO (liftIO (print boom))

My problem is that I control `doTinIO', but someone else provides
the computation (T a). I cannot force callers to strictly evaluate
their computations.

I've tried three other variants (given below) that are all
nearly equivalent.

> handler :: Exception -> IO (Either String a)
> handler = return . Left . ("EX: "++) . show
>
> doTinIO2 :: T a -> IO (Either String a)
> doTinIO2 ta = catch (runErrorT ta >>= evaluate) handler
>
> doTinIO3 :: T a -> IO (Either String a)
> doTinIO3 ta = do
>  esa <- catch (runErrorT ta) handler
>  case esa of
>Right a -> catch (evaluate (return a)) handler
>l -> return l
>
> doTinIO4 :: T a -> IO (Either String a)
> doTinIO4 ta = catch (runErrorT ta) handler

*Main> doTinIO2 b1
Right *** Exception: divide by zero
*Main> doTinIO3 b1
Right *** Exception: divide by zero
*Main> doTinIO4 b1
Right *** Exception: divide by zero

Any suggestions? Thanks all.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] A type signature inferred by GHCi that is rejected when written explicitly

2008-07-07 Thread Pablo Nogueira
I find this interesting,

GHCi accepts a function |dmap| which I show below and infers its type,
but if I annotate the function with the inferred type, GHCi's
type-checker rejects it.

I'm trying to generalise the datatype-generic dmap:

< dmap :: Bifunctor s => (a -> b) -> Fix s a -> Fix s b
< dmap f = In . bimap (dmap f) f . out

where
> data Fix s a = In { out :: s (Fix s a) a  }
>
> class Bifunctor s where
> bimap :: (a -> c) -> (b -> d) -> s a b -> s c d

The idea is that recursive types are represented by their
(lamba-lifted) functors, eg:

> data ListF b a = NilF | ConsF a b

> instance Bifunctor ListF where
>   bimap f g NilF   =  NilF
>   bimap f g (ConsF a b)=  ConsF (g a) (f b)

I now define two classes:

> class From a c x where
> from :: a x -> c x
>
> class To a c y where
> to :: c y -> a y

And a generic |gmap| which given the map for |c| and a mapping for |x|
delivers the map for |a|:

> type GMap t x y = (x -> y) -> t x -> t y
>
> gmap :: (From a c x, To a c y) => GMap c x y -> GMap a x y
> gmap gmc gmx = to . gmc gmx . from

I want to write |dmap| as a special case of |gmap|, but I can't even
get there. If I write

> dmap f = to . bimap (dmap f) f . from

GHCi infers it has type (up to renaming):

(From a1 (s (a1 x)) x,  Bifunctor s,  To  a2 (s (a2 y)) y) => (x -> y)
-> a1 x -> a2 y

But if I cut and paste the type into the code I get type errors:

   Could not deduce (From a1 (s1 (a11 x)) x) ...
Could not deduce (From a11 (s1 (a11 x)) x, To a21 (s1 (a21 y)) y) ...
Could not deduce (From a1 (s1 (a11 x)) x) ...

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


Re: [Haskell-cafe] Is there anything manifestly stupid about this code?

2008-07-07 Thread Luke Palmer
On Mon, Jul 7, 2008 at 2:21 PM, Michael Feathers
<[EMAIL PROTECTED]> wrote:
> Thanks.  Here's a newb question: what does strictness really get me in this
> code?

A bit of speed and memory improvements, I suspect.  The type
(Double,Double) has three boxes, one for the tuple and one for each
double.  The type Complex, which is defined as

data Complex a = !a :+ !a

has one box (after -funbox-strict-fields has done its work), the one
for the type as a whole.  So it will end up using less memory, and
there will be fewer jumps to evaluate one (a jump is made for each
box).

> BTW, I only noticed the Complex type late.  I looked at it and noticed that
> all I'd be using is the constructor and add.  Didn't seem worth the  change.

You would also be using the multiply and magnitude functions!  And you
would gain code readability, since you could define:

mandel c z = z^2 + c
trajectory c = iterate (mandel c) 0

Which is basically the mathematical definition right there in front of
you, instead of splayed out all over the place.

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


Re: [Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support

2008-07-07 Thread Miguel Mitrofanov

"rlwrap" adds readline support to everything.

On 7 Jul 2008, at 16:17, Chris Eidhof wrote:


Hey all,

When compiling GHC 6.8.3 on OS X, I ended up with a GHCi without  
readline support. That makes interacting quite hard, especially  
because the Backspace-key didn't even work. With some help on irc  
from Baughn and by reading a blog post from Paul Brown, I managed to  
get readline working after all.


After installing readline from fink, I had to pass the following  
options to configure:


./configure --with-readline-includes=/sw/include/readline --with- 
readline-libraries=/sw/lib


After that make and sudo make install worked just fine, and I had  
readline again! I wrote this down in case anybody else has had the  
same problems.


-chris

___
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] Is there anything manifestly stupid about this code?

2008-07-07 Thread Michael Feathers


Thanks.  Here's a newb question: what does strictness really get me in 
this code?


BTW, I only noticed the Complex type late.  I looked at it and noticed 
that all I'd be using is the constructor and add.  Didn't seem worth the 
 change.


Michael

Derek Elkins wrote:

To answer the question in your subject, yes!  We have a complex type.
Not only does that make the code simpler and more obvious and idiomatic,
but it's also more efficient because for this use you'd really prefer a
strict pair type for "Point", and complex is strict in it's components.

On Sun, 2008-07-06 at 21:02 -0400, Michael Feathers wrote:
Decided a while ago to write some code to calculate the Mandelbrot set 
using the escape iterations algorithm.  Discovered after mulling it 
about that I could just built it as an infinite list of infinite lists 
and then extract any rectangle of values that I wanted:


type Point = (Double, Double)



sq :: Double -> Double
sq x = x ^ 2

translate :: Point -> Point -> Point
translate (r0, i0) (r1, i1) =
   (r0 + r1, i0 + i1)

mandel :: Point -> Point
mandel (r, i) =
   (sq r + sq i, 2 * r * i)

notEscaped :: Point -> Bool
notEscaped (r, i) =
   (sq r + sq i) <= 4.0

trajectory :: (Point -> Point) -> [Point]
trajectory pointFunction =
   takeWhile notEscaped $ iterate pointFunction seed
 where seed = (0.0, 0.0)

escapeIterations :: (Point -> Point) -> Int
escapeIterations =
   length . tail . take 1024 . trajectory

mandelbrot :: Double -> [[Int]]
mandelbrot incrementSize =
   [[ escapeIterations $ translate (x, y) . mandel
 | x <- increments]
 | y <- increments] where
 increments = [0.0, incrementSize .. ]

window :: (Int, Int) -> (Int, Int) -> [[a]] -> [[a]]
window (x0, y0) (x1, y1) = range x0 x1 . map (range y0 y1) where
   range m n = take (n - m) . drop m


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






--
Now Playing: Clammbon - 246
http://youtube.com/watch?v=PO77bN8W1mA


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


[Haskell-cafe] Compiling GHC 6.8.3 on OS X with readline support

2008-07-07 Thread Chris Eidhof

Hey all,

When compiling GHC 6.8.3 on OS X, I ended up with a GHCi without  
readline support. That makes interacting quite hard, especially  
because the Backspace-key didn't even work. With some help on irc from  
Baughn and by reading a blog post from Paul Brown, I managed to get  
readline working after all.


After installing readline from fink, I had to pass the following  
options to configure:


./configure --with-readline-includes=/sw/include/readline --with- 
readline-libraries=/sw/lib


After that make and sudo make install worked just fine, and I had  
readline again! I wrote this down in case anybody else has had the  
same problems.


-chris

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


Re: [Haskell-cafe] Interesting feature

2008-07-07 Thread fero

Thanks a lot Neil,
I will definitely read it. I searched google and found the same article here
for free
http://www.cs.chalmers.se/~emax/wired/documents/LP_HFL07.pdf

I didn't know that Haskell commuity is so alive. Much more answers in much
less time than when I wrote something to jav:)

Fero


Neil Mitchell wrote:
> 
> Hi
> 
>>  Hi I have read in one tutorial (I can't find it again, but it was
>> probably
>>  either one on ibm, gentle introduction or yaht), that it is possible to
>>  define relationships between free variables and the same program can be
>> used
>>  to calculate either first variable when second is set or second when
>> first
>>  is set.
> 
> Here is how to do it in Haskell:
> 
> http://portal.acm.org/citation.cfm?id=1291201.1291207
> 
> Thanks
> 
> Neil
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Interesting-feature-tp18311432p18314566.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Interesting feature

2008-07-07 Thread Neil Mitchell
Hi

>  Hi I have read in one tutorial (I can't find it again, but it was probably
>  either one on ibm, gentle introduction or yaht), that it is possible to
>  define relationships between free variables and the same program can be used
>  to calculate either first variable when second is set or second when first
>  is set.

Here is how to do it in Haskell:

http://portal.acm.org/citation.cfm?id=1291201.1291207

Thanks

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


Re: [Haskell-cafe] Interesting feature

2008-07-07 Thread Jules Bean

fero wrote:

Hi I have read in one tutorial (I can't find it again, but it was probably
either one on ibm, gentle introduction or yaht), that it is possible to
define relationships between free variables and the same program can be used
to calculate either first variable when second is set or second when first
is set. I have understood this as if I set first free variable, run program
and write name of second variable and I get result, and vice versa. I don't
know if I understood it well. It looks really interesting but I can't figure
out how to do it. Is this really possible? (I doubt.) If yes show example
please. 


See also metafont, which defines equational relationships between 
variables and solves.


Jules

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


Re: [Haskell-cafe] Interesting feature

2008-07-07 Thread Janis Voigtlaender

Robin Green wrote:

On Mon, 07 Jul 2008 12:30:34 +0200 (CEST)
Henning Thielemann <[EMAIL PROTECTED]> wrote:



 Actually the type system of Haskell is also logic programming. I
have implemented a simple kind of logic programming using lazy peano
numbers: http://darcs.haskell.org/unique-logic/



There is also Curry which is basically Haskell extended with features
from logic programming. There you get to use ordinary values instead of
having to use types. However, it seems that Curry's solution finding
mechanism is built-in to the language and cannot be modified (e.g. for
performance reasons) without modifying the language implementation. (I


Actually, I think it can:

http://dblp.uni-trier.de/rec/bibtex/conf/iclp/HanusS98

Also more recently, I heard of a way to abstract a nondeterministic
Curry value into its explicit search tree, which one can then traverse
to one's own liking. Obviously, people on the Curry list will know more
about the details...

Ciao, Janis.

--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:[EMAIL PROTECTED]

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


RE: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC or Hugs+Yhc)

2008-07-07 Thread Simon Peyton-Jones
I think GHC is right here. See
http://haskell.org/onlinereport/decls.html#instance-decls
esp the bit starting "It is illegal to give a binding..."

Simon


| -Original Message-
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neil
| Mitchell
| Sent: 06 July 2008 00:03
| To: Haskell Cafe
| Subject: [Haskell-cafe] Re: Definition of hidden instance members (bug in GHC 
or Hugs+Yhc)
|
| >  This is either a GHC bug, or a Yhc+Hugs bug - I'm not sure which, but
| >  the compilers disagree:
| >
| >  import Prelude hiding ((==))
| >  data Foo = Foo
| >  instance Eq Foo where
| > (==) a b = True
|
| I was thinking that GHC's behaviour seems more sensible, but the
| following fails:
|
| import qualified Module as M
|
| instance MClass Foo where
|  M.foo = undefined
|
| M. is not allowed as a prefix of a function, which makes resolving
| ambiguities hard unless the compiler solves the issue for you (as Hugs
| and Yhc do)
|
| Thanks
|
| Neil
| ___
| 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] Interesting feature

2008-07-07 Thread Robin Green
On Mon, 07 Jul 2008 12:30:34 +0200 (CEST)
Henning Thielemann <[EMAIL PROTECTED]> wrote:

>   Actually the type system of Haskell is also logic programming. I
> have implemented a simple kind of logic programming using lazy peano
> numbers: http://darcs.haskell.org/unique-logic/

There is also Curry which is basically Haskell extended with features
from logic programming. There you get to use ordinary values instead of
having to use types. However, it seems that Curry's solution finding
mechanism is built-in to the language and cannot be modified (e.g. for
performance reasons) without modifying the language implementation. (I
think the same would be true for logic programming with Haskell types.)
-- 
Robin
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Interesting feature

2008-07-07 Thread Henning Thielemann


On Mon, 7 Jul 2008, fero wrote:


Hi I have read in one tutorial (I can't find it again, but it was probably
either one on ibm, gentle introduction or yaht), that it is possible to
define relationships between free variables and the same program can be used
to calculate either first variable when second is set or second when first
is set. I have understood this as if I set first free variable, run program
and write name of second variable and I get result, and vice versa. I don't
know if I understood it well. It looks really interesting but I can't figure
out how to do it. Is this really possible? (I doubt.) If yes show example
please.


Are you talking about logic programming and PROLOG?
$ pl  # swi-prolog

?- plus(X,2,3).

X = 1 ;

No
?- plus(1,X,3).

X = 2 ;

No
?- plus(1,2,X).

X = 3 ;

No


 Actually the type system of Haskell is also logic programming. I have 
implemented a simple kind of logic programming using lazy peano numbers:

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


[Haskell-cafe] Interesting feature

2008-07-07 Thread fero

Hi I have read in one tutorial (I can't find it again, but it was probably
either one on ibm, gentle introduction or yaht), that it is possible to
define relationships between free variables and the same program can be used
to calculate either first variable when second is set or second when first
is set. I have understood this as if I set first free variable, run program
and write name of second variable and I get result, and vice versa. I don't
know if I understood it well. It looks really interesting but I can't figure
out how to do it. Is this really possible? (I doubt.) If yes show example
please. 

Thanks
Fero
-- 
View this message in context: 
http://www.nabble.com/Interesting-feature-tp18311432p18311432.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Reading A Monad Tutorial (Re: [Haskell-cafe] Ode from a Haskeller to a Schemer)

2008-07-07 Thread Ketil Malde

(With apologies to Queen.)

Is this the RealWorld#?
Is this I/O I see?
Caught in a monad - 
No escape back to purity

Open a file, it wipes out my smile to see
I'm just a programmer, don't need a Ph.D
I'm easy come, easy go
Don't need this high brow
weird monadic action, no real reaction
for me, from G-HC

Hey man, I just found out that
it is easy to achieve
using unsafeInterleave
and unsafe...PerformIO
but people tell me I should let those go
Oh man, no-o-o
I'm about to start to cry
If I can't make this stuff compile tomorrow
I will just carry on
Nothing really matters.

Too late - 'cause I got it now
there are monads all around
IO, State and lists abound
It's easy, like those people say
but my program got abstracted all away!
Maybe - o o o, 
It's a monad too, I know
Why should I use another language at all?

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe