Re: [Haskell] Fwd: Mutually dependent functions

2007-06-12 Thread Tomasz Zielonka
On Tue, Jun 12, 2007 at 05:19:37PM +0200, Wolfgang Jeltsch wrote:
> It is always the *least* fixpoint. For example, (0 *) has the fixpoint _|_ 
> (because 0 * _|_ = _|_) but every integer is also  a fixpoint of it.  

0 * 5 = 5 ?

You probably meant (1 *) or (0 +).

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


Re: [Haskell] Re: Even higher-order abstract syntax: typeclasses vs GADT

2007-01-22 Thread Tomasz Zielonka
On Mon, Jan 22, 2007 at 11:34:32PM +0100, Benjamin Franksen wrote:
> I would be interested whether you can not only /check/ well-typedness, but
> also /establish/ it, i.e. is it possible to have the input to the
> type-checker be an /untyped/ representation (such as obtained by parsing a
> program in text form) and the output be a typed one (or else a type error)?
> 
> From my very limited understanding of these issues I would say it is not
> possible, neither with type-classes nor with G[AR]DTs because it would mean
> the return type of the function 'typecheck' would have to vary depending on
> the input data, hence you'd need a genuinely dependent type system for such
> a feat.

You can do this with existential types and with higher-rank polymorphism (the
latter if you write your parser in CPS).

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


Re: [Haskell] ANNOUNCE: Phooey 0.1 -- Functional user interface library

2007-01-17 Thread Tomasz Zielonka
On Wed, Jan 17, 2007 at 01:17:33AM -0800, Conal Elliott wrote:
>   - Phooey is now used in TV: http://haskell.org/haskellwiki/TV .

Is this so that you can use this famous advertising phrase: "as seen on
TV", ehm..., "... in TV" ;-)

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


[Haskell] Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-24 Thread Tomasz Zielonka
On Fri, Nov 24, 2006 at 10:31:27AM +0100, Lemmih wrote:
> Worked for me with mplayer+w32codecs.

Oops! I missed the "Download" link and tried to download through
"Watch" ;-) Thanks!

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


[Haskell] Re: [Haskell-cafe] SimonPJ and Tim Harris explain STM - video

2006-11-24 Thread Tomasz Zielonka
On Thu, Nov 23, 2006 at 12:56:00PM -, Bayley, Alistair wrote:
> http://channel9.msdn.com/Showpost.aspx?postid=231495
> 
> The links to the video are a couple of yellow buttons at the bottom of
> the article: "Watch" or "Download".
> 
> I haven't watched this yet (it's nearly an hour long, I think). Found
> via reddit (http://reddit.com).
> 
> Haskeller's on TV (sort of...) woot woot!

Does anybody know how to watch this on Linux? I would prefer to simply
download the movie file and use MPlayer on that, but I failed.

.. or on Mac OS X (haven't tried yet)

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


Re: [Haskell] ANN: Efficient, dynamically compiled, lazy functional semantics on JVM, having tight integration with the Java language

2006-09-26 Thread Tomasz Zielonka
On Tue, Sep 26, 2006 at 09:22:21PM -0700, Luke Evans wrote:
> Here are a few 'highlights' from our feature list:
> - A lazily evaluated, strictly-typed language called CAL, with many
> similarities to Haskell

Do you think that CAL would be a good target for a Haskell compiler?
In other words, would it be a good idea to use CAL as an intermediate
language for a Haskell -> Java byte-code compiler?

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


Re: [Haskell] building shared objects

2006-09-14 Thread Tomasz Zielonka
On Fri, Sep 15, 2006 at 01:45:46AM +1000, Jeremy Wazny wrote:
> The performance of the Haskell code is not an issue.
> [...]
> The alternative is to admit defeat and rewrite all the Haskell code as
> C++, which is pretty depressing.

If performance is not an issue, then maybe another alternative
- package your Haskell code as a separate program, with which your C++
program communicates through pipes using some simple protocol. It
works for me.

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


Re: [Haskell] Proposal: unification of style of function/data/type/class definitions

2006-09-10 Thread Tomasz Zielonka
On Sun, Sep 10, 2006 at 10:08:22AM +0400, Bulat Ziganshin wrote:
> we can improve readability of various declarations by using the same
> scheme:
> 
> class Monad m | Functor m, Monoid m where ...
> 
> instance Monad (WriterT m) | Monad m where ...
> 
> sequence :: [m a] -> m [a] | Monad m

I am not entirely sure, but I think this syntax for type class
context is used in the Concurrent Clean language.

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


Re: [Haskell] putStr is not evaluated in the correct order

2006-09-03 Thread Tomasz Zielonka
On Sat, Sep 02, 2006 at 05:11:33PM -0700, Jeremy Shaw wrote:
> GHCi and the compiled program do not buffer the output in quite the
> same way.

This comes up so often that perhaps GHCi should advertise those
differences. For example, the starting message could say something
like this:

   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 6.?, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

For a list of differences between GHCi-interpreted and GHC-compiled
programs, type :differences

Loading package base-1.0 ... linking ... done.

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


Re: [Haskell] String permutation

2006-07-26 Thread Tomasz Zielonka
On Tue, Jul 25, 2006 at 09:44:36PM -0700, Sukit Tretriluxana wrote:
> permute :: String -> [String]
> permute str = rotate str len len
>   where len = length str
> 
> rotate :: String -> Int -> Int -> [String]
> rotate _ _ 0 = []
> rotate s 1 _ = [s]
> rotate (ch:chs) len rcnt =
>   map (\x -> ch : x) (rotate chs (len-1) (len-1))
>   ++
>   rotate (chs ++ [ch]) len (rcnt-1)

Some notes:

Your permute gives 0 permutations for an empty input String, but there
should be 1 - the empty string. Note that 0! == 1

The name "rotate" suggests that this function does less than it actually
does.

Also, your functions could easily work for lists with other types of
values, not only for [Char], but you unneccesarily restrict their types.

> I am more than certain that this simple program can be rewritten to be more
> succinct and possibly more efficient using Haskell's features. So I would
> like to ask if any of you would kindly show me an example.

There are some examples at http://www.haskell.org/hawiki/PermutationExample

Below is my favourite way to compute permutations.

import List

perms [] = [[]]
perms (x:xs) = [ p ++ [x] ++ s | xs' <- perms xs
   , (p, s) <- zip (inits xs') (tails xs') ]

It's not too efficient - there are other versions that exhibit better
sharing of list tails, etc. Also, the resulting list is not
lexicographically ordered (when the input one is sorted). But I like the
look of this code.

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


Re: [Haskell] ANN: monadic probabilistic functional programing

2006-07-21 Thread Tomasz Zielonka
On Fri, Jul 21, 2006 at 10:26:04PM +0200, Stefan Karrmann wrote:
> I have renamed all files. Because of this the darcs diff contains *all*
> source lines. Then it is not only a patch but also the complete original
> work. Moreover, the patch does not contain a move from or unlink of the old
> locations.

If the original code was already in a darcs repository, you can create
a darcs patch bundle by 'darcs send'ing against a repository, which
contains only the original patches. You do it like this:

$ cd repository-with-your-extensions
$ darcs send -o my.patchse original-repository

Now if someone has an original repository, he/she can apply your patches
in this repository. The patch bundle can still contain parts of the
original work as parts of primitive patches.

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


Re: [Haskell] Re: ANNOUNCE: FPS - FastPackedStrings 0.2

2006-04-20 Thread Tomasz Zielonka
On Thu, Apr 20, 2006 at 10:32:37AM +1000, Donald Bruce Stewart wrote:
> ashley:
> > Donald Bruce Stewart wrote:
> > 
> > >Interface:   
> > >http://www.cse.unsw.edu.au/~dons/fps/Data.FastPackedString.html
> > 
> > Given that FastString turns out to be an array of Word8, why are you using 
> > Char at all?
> 
> Convenience. Some historical legacy from darcs. And others have
> contributed patches specifically to add more Word8 support.

I think the biggest barrier to using Word8 operations on String-like
types is the Read/Show instance for Word8, which works like for other
Word types:

  Prelude Data.Word> map (toEnum . fromEnum) "Haskell" :: [Word8]
  [72,97,115,107,101,108,108]

Maybe we should introduce a Char8 type, or something like that, which
would have the nice Stringy presentation?

There is also a problem with literals. How about solving it by adding
a Num-like Character class? Consider:

Prelude> :t 1
1 :: (Num t) => t
Prelude> :t "abc"
"abc" :: CharAscii c => [c]
Prelude> :t "aąbcć"
"aąbcć" :: CharUnicode c => [c]

or even:

Prelude> :t "aąbcć"
"aąbcć" :: CharacterPolish c => [c]

;-)

And a String class would allow typing FastPackedString literals directly.

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


Re: [Haskell] Haskell as a disruptive technology?

2006-03-30 Thread Tomasz Zielonka
On Thu, Mar 30, 2006 at 11:39:34AM +0100, Tim Harris wrote:
> BTW, I've put a copy of another recent STM-Haskell paper online at
> http://research.microsoft.com/~tharris/drafts/2006-invariants-draft.pdf.
> It's about defining invariants over transactionally-managed data
> structures -- feedback's very welcome!

Here is my feedback: great stuff! :-)

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


Re: [Haskell] unsafeInterleaveST

2006-02-06 Thread Tomasz Zielonka
On Mon, Feb 06, 2006 at 06:31:17PM +0300, Bulat Ziganshin wrote:
> is it possible to implement unsafeInterleaveST?

I hope not. You surely shouldn't be able to implement this function
without unsafe* functions, because that would break ST's guarantees.
Hell, you would be able to return frozen ST computations from runST!

Best regards
Tomasz

-- 
I am searching for programmers who are good at least in
(Haskell || ML) && (Linux || FreeBSD || math)
for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] The Haskell road ... to Google

2006-01-19 Thread Tomasz Zielonka
On Thu, Jan 19, 2006 at 09:09:36AM -0800, Ralf Lammel wrote:
> Google's MapReduce Programming Model -- Revisited
> Draft; To be submitted; feedback appreciated; 27 pages.
> http://www.cs.vu.nl/~ralf/MapReduce
> Executive summary: The seminal MapReduce paper had been briefly
> discussed at LTU without really going into technical details. The
> present paper discovers the concepts from a functional programming
> perspective. Did you ever wonder why MapReduce is called MapReduce?


It's so good to see that I and Google have the same ideas ;-)


Best regards
Tomasz

-- 
I am searching for programmers who are good at least in
(Haskell || ML) && (Linux || FreeBSD || math)
for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] A question about fundeps <-> GADT interaction

2005-12-29 Thread Tomasz Zielonka
On Thu, Dec 29, 2005 at 12:39:01PM +, Bruno Oliveira wrote:
> A second alternative would be to simulate your GADT with a type class and 
> your constructors with the functions of that type class:
>
> [...]
> 
> As a remark, this is a church encoding of the GADT.
>
> [...]
>
> Now you can encode functions on the GADT as instances of this type class:

This is very interesting. Thanks!

I'll try to apply this technique to my problem.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] A question about fundeps <-> GADT interaction

2005-12-29 Thread Tomasz Zielonka
On Thu, Dec 29, 2005 at 09:48:04AM -, Simon Peyton-Jones wrote:
> Intriguing!  I'm afraid it'll be some time before your code works,
> though.

No problem, I can wait.

> First I have to get GADTs and type classes to play together nicely,
> which I am hoping to do during Jan/Feb.  Then I'll have to think about
> the interaction between GADTs and fundeps. 

I wonder if my problem can't be solved with Associated Type Synonyms.
But was interaction of ATS and GADT explored at all?

> As of today, if it works at all, it's quite amazing.

I am amazed too. After all, Oleg found a way to make "untype" compile
(but there are still problems with more complicated functions).

There is also his idea for doing it in a different way, but haven't
tested it yet.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: Conditional typechecking with GADTs

2005-12-27 Thread Tomasz Zielonka
On Tue, Dec 27, 2005 at 08:07:39PM -0800, [EMAIL PROTECTED] wrote:
> 
> Tomasz Zielonka wrote:
> > The papers on GADTs have an example showing how you can transform,
> > traverse and evaluate ASTs (or terms) with more type safety. I've
> > used such an approach in one of my applications and it works remarkably
> > well.
> >
> > However, I would like to be able to "turn off" that type-safety
> > in some parts of code, for example to separate parsing from typing.
> > I thought I found a way to do this, because I was able to create Typed
> > (with all consistency checking) and Untyped (without consistency
> > checking) terms. Unfortunately I seem to be unable to write any useful
> > function on such terms - GHC complains that there are type errors.
> 
> The present message shows what seems to be a more fruitful approach to
> writing terms whose typechecking can be `postponed', perhaps
> indefinitely. The approach tries to play to the strengths of GADTs and
> avoid their weaknesses.
> [...]

Wow! This is cool!

But I'm not sure how far I can go with this approach. I'll see if this
can be used to separate parsing from type-checking.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] GADTs and GHC

2005-12-27 Thread Tomasz Zielonka
On Fri, Oct 14, 2005 at 04:35:24PM +0100, Simon Peyton-Jones wrote:
> Stephanie and Dimitrios and I are now busy revising our wobbly-types
> GADT paper (which is implemented in GHC, but never published
> http://research.microsoft.com/%7Esimonpj/papers/gadt/index.htm).  We
> have a *far* simpler story now... but that means it'll reject some
> programs that would be accepted by the earlier version.  We don't think
> this loss of expressiveness is important, but we'd like to check.  Hence
> this message:
> 
>   If you use GADTs, would you to send us your GADT code, 
>   so we can check that we can still compile it?  

My current uses of GADTs belong to the company I work for, so it would
be easier for me if *I* could check from time to time. Is the code
publicly available?

What I really care about at this moment is this: I've came up with an
interesting (IHMO) idea that doesn't work with current GADT
implementation. If it worked, it would really help me improve my code.
Here is a recent thread, in case you missed it:

http://www.haskell.org//pipermail/haskell/2005-December/017140.html
http://www.haskell.org//pipermail/haskell/2005-December/017142.html

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: A question about fundeps <-> GADT interaction

2005-12-27 Thread Tomasz Zielonka
On Fri, Dec 23, 2005 at 12:10:07PM +0100, Tomasz Zielonka wrote:
> On Fri, Dec 23, 2005 at 03:34:40AM -, [EMAIL PROTECTED] wrote:
> > 
> > [Sorry for possible duplication, our DNS server seems to be broken,
> >  and the sysadm is on vacation]
> > 
> > I don't think that is the problem with GADTs. The following works
> > 
> > > untype :: Term f a -> Term Untyped ()
> > > untype (Lit x)  = Lit x
> > > untype (Succ t) = Succ (untype t)
> > > untype (IsZero t)   = IsZero ((untype t)::Term Untyped ())
> > > untype (If c t e)   = If ((untype c)::Term Untyped ()) 
> > >  ((untype t)::Term Untyped ())
> > >  ((untype e)::Term Untyped ())
> 
> I just checked that the only required change is the one
> in type signature. But I can't explain it at this moment.

I tried to implement another function:

  mapChildren :: (forall a. Term f a -> Term f a) -> Term f b -> Term f b
  mapChildren fun t@(Lit x) = t
  mapChildren fun (IsZero t) = IsZero (fun t)
  mapChildren fun (Succ t) = Succ (fun t)
  mapChildren fun (If c t e) = If (fun c) (fun t) (fun e)

It is supposed to be similar to gmapT from Data.Generics - apply 'fun'
to every immediate Expr child of the node. Unfortunately, I don't know
how to make it compile. I tried a couple of different type signatures.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Boxing (Day) Question

2005-12-26 Thread Tomasz Zielonka
On Mon, Dec 26, 2005 at 02:22:57PM +0100, Niklas Sorensson wrote:
> That reminds me of something that I have wondered about for some
> time. Why is there such reluctance to instantiate polymorhic functions
> with the types with which they are used? (This isn't done automatically
> in complilers right?)
> 
> I can imagine that it is akward to delay code generation until all uses
> of a function are known, and that in some cases there may be infinitely
> many instances needed. But apart from that, what are the reasons
> against this implementation technique?

What made you think that this technique isn't used?

It is used in GHC. However, there are cases where it can't be used, most
notably with polymorphic recursion, existential types or higher-rank
polymorphism.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: A question about fundeps <-> GADT interaction

2005-12-23 Thread Tomasz Zielonka
On Fri, Dec 23, 2005 at 03:34:40AM -, [EMAIL PROTECTED] wrote:
> 
> [Sorry for possible duplication, our DNS server seems to be broken,
>  and the sysadm is on vacation]
> 
> I don't think that is the problem with GADTs. The following works
> 
> > untype :: Term f a -> Term Untyped ()
> > untype (Lit x)  = Lit x
> > untype (Succ t) = Succ (untype t)
> > untype (IsZero t)   = IsZero ((untype t)::Term Untyped ())
> > untype (If c t e)   = If ((untype c)::Term Untyped ()) 
> >((untype t)::Term Untyped ())
> >((untype e)::Term Untyped ())

I just checked that the only required change is the one
in type signature. But I can't explain it at this moment.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: A question about fundeps <-> GADT interaction

2005-12-22 Thread Tomasz Zielonka
On Fri, Dec 23, 2005 at 03:34:40AM -, [EMAIL PROTECTED] wrote:
> 
> [Sorry for possible duplication, our DNS server seems to be broken,
>  and the sysadm is on vacation]
> 
> I don't think that is the problem with GADTs. The following works
> 
> > untype :: Term f a -> Term Untyped ()
> > untype (Lit x)  = Lit x
> > untype (Succ t) = Succ (untype t)
> > untype (IsZero t)   = IsZero ((untype t)::Term Untyped ())
> > untype (If c t e)   = If ((untype c)::Term Untyped ()) 
> >((untype t)::Term Untyped ())
> >((untype e)::Term Untyped ())
> 
> Here's a more extensive example:
> 
> > tlit :: Int->Term Typed Int
> > tlit = Lit
> >
> > [l0,l1,l2] = map tlit [0..]
> >
> > --ex2 :: Term Untyped ()
> > ex2' =
> > If  (IsZero (Succ (Lit 0)))
> > (untype l1)
> > (IsZero (untype l2))
> 
> ex2' of course won't typecheck if `untype' are removed.

Great! Thanks! :-)

Could you explain why additional type annotations are required?

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] A question about fundeps <-> GADT interaction

2005-12-22 Thread Tomasz Zielonka
Hello!

(This message is a literate Haskell module)

> {-# OPTIONS -fglasgow-exts -fno-warn-missing-methods #-}
> module Term where

The papers on GADTs have an example showing how you can transform,
traverse and evaluate ASTs (or terms) with more type safety. I've
used such an approach in one of my applications and it works remarkably
well.

However, I would like to be able to "turn off" that type-safety
in some parts of code, for example to separate parsing from typing.
I thought I found a way to do this, because I was able to create Typed
(with all consistency checking) and Untyped (without consistency
checking) terms. Unfortunately I seem to be unable to write any useful
function on such terms - GHC complains that there are type errors.

I think this is because of the known problem with current GADT
implementation in GHC, namely - bad GADT / type-classes interaction. I
would be very happy to hear that it will be solved in GHC 6.6.

I use an additional type parameter for Term that determines whether
the Term is used as Typed or Untyped. Typed terms will have types
(Term Typed Int), (Term Typed Bool), ..., but Untyped terms only
one type: (Term Untyped ())

I use a multiparameter type-class with fundeps to describe a relation
between the Typed/Untyped tag used, the types actually used in data
constructors and the resulting "phantom" type.

> class F f a b | f a -> b where
> -- these methods are just for experiments in GHCi
> a2b :: f -> a -> b
> b2a :: f -> b -> a

> data Typed = Typed
> instance F Typed a a where

> data Untyped = Untyped
> instance F Untyped a () where

> data Term f a where
> Lit :: (F f Int int)=>
> Int -> Term f int
> Succ:: (F f Int int)=>
> Term f int -> Term f int
> IsZero  :: (F f Int int, F f Bool bool) =>
> Term f int -> Term f bool
> If  :: (F f Bool bool, F f a a')=>
> Term f bool -> Term f a' -> Term f a' -> Term f a'

Some examples:

a typeable term

> ex1 :: Term Untyped ()
> ex1 =
> If  (IsZero (Succ (Lit 0)))
> (Lit 1)
> (Lit 2)

the same as ex1, but Typed

> ex1' :: Term Typed Int
> ex1' =
> If  (IsZero (Succ (Lit 0)))
> (Lit 1)
> (Lit 2)

a term that has type bug, but will be accepted as Untyped

> ex2 :: Term Untyped ()
> ex2 =
> If  (IsZero (Succ (Lit 0)))
> (Lit 1)
> (IsZero (Lit 2))

Here is the function that doesn't type check (you can comment it out to
get the rest of code to compile).

> -- A simple cast from typed terms to untyped terms
> untype :: Term Typed a -> Term Untyped ()
> untype (Lit x)  = Lit x
> untype (IsZero t)   = IsZero (untype t)
> untype (Succ t) = Succ (untype t)
> untype (If c t e)   = If (untype c) (untype t) (untype e)

The error given by GHC (for the commented "untype" function) is:

  T.hs:52:8:
  Couldn't match the rigid variable `a' against `Int'
`a' is bound by the type signature for `untype'
Expected type: Int
Inferred type: a
  When using functional dependencies to combine
F Typed a a, arising from the instance declaration at T.hs:13:0
F Typed Int a,
  arising from the pattern for `Lit' at T.hs:52:8-12 at T.hs:52:8-12
  In the definition of `untype': untype (Lit x) = Lit x
  Failed, modules loaded: none.

So it seems it can't infer that the 'a' in (F Typed Int a) is Int.
At the same time...

  *T> :t a2b
  a2b :: (F f a b) => f -> a -> b
  *T> :t a2b Untyped
  a2b Untyped :: a -> ()
  *T> :t a2b Typed
  a2b Typed :: b -> b   -- see? it knows a and b are equal!
  *T> :t b2a Typed
  b2a Typed :: b -> b

If there is another way to do this right now (conveniently, Oleg! ;-), I
would be more than happy to hear about it.

If this worked, it would be a cool trick and a nice example for GADT
use. Let me know if it was proposed before.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Silly question on interactive import

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 01:08:01PM +0100, Jerzy Karczmarczuk wrote:
> Mmm, no. The file cannot be loaded, since it won't compile without that
> incriminated module...

I'm sorry, seems like I misunderstood your question - you have
to add an import to the file.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Silly question on interactive import

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 12:03:17PM +0100, Jerzy Karczmarczuk wrote:
> Could you remind me what is the easiest way to load interactively a specific
> module before loading a afile into ghci? For example, I have a file parse.hs
> with some functions such as isUpper, which belongs to the module Char.
> 
> I thought that writing
> 
> :m + Char
> :l parse

Try doing it in reverse order.
:load resets the session, or whatever it is called
:module +/- doesn't

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] TArray?

2005-12-13 Thread Tomasz Zielonka
On Tue, Dec 13, 2005 at 01:32:46PM +0100, Sebastian Sylvan wrote:
> Are there plans to include a mutable array for use in the STM monad,
> or a good reason for why this is not needed? Also, an unboxed version
> would be nice.

Why not use an (Array idx (TVar a)) ?

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Type problem

2005-12-13 Thread Tomasz Zielonka
On Tue, Dec 13, 2005 at 10:42:15AM +0100, Tomasz Zielonka wrote:
> On Tue, Dec 13, 2005 at 09:46:31AM +0100, Emil Axelsson wrote:
> > Is this just a limitation of the current GATDs, or is it unreasonable of me 
> > to expect this to work?
> 
> AFAIK it is a current limitation of GADTs, which will be removed in GHC
> 6.6.

Of course it is the limitation that will be removed, not GADTs ;-)

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Type problem

2005-12-13 Thread Tomasz Zielonka
On Tue, Dec 13, 2005 at 09:46:31AM +0100, Emil Axelsson wrote:
> Is this just a limitation of the current GATDs, or is it unreasonable of me 
> to expect this to work?

AFAIK it is a current limitation of GADTs, which will be removed in GHC
6.6.

> Is there any workaround, such as coercing the type of the value function?

I've had the same problem myself. The workaround is to replace some of
type-class constraints with "witness" GADTs. The code I attached
shows how you can do it. I chose to make HasX a GADT, and introduce
the HasX' type-class, but the latter is only for convenience. Note
the subtle change in Val's definition:

data Val a where
   ...
   X :: HasX a -> Val a  -- Unconstrained
   ^^

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
{-# OPTIONS -fglasgow-exts #-}

data Number = XN -- Unconstrained
 | N Int  -- Constrained

data HasX a where
   HasX_Number :: HasX Number

xVal :: HasX a -> a
xVal HasX_Number = XN

class HasX' a where
hasX :: HasX a

instance HasX' Number where
hasX = HasX_Number

x :: HasX' a => Val a
x = X hasX

data Val a where
   P :: a -> Val a   -- Primitive

   T2 :: (Val a1, Val a2) -> Val (a1,a2)

   X :: HasX a -> Val a  -- Unconstrained

value :: Val a -> a
value (X hx)   = xVal hx
value (P a)= a
value (T2 (a1,a2)) = (value a1, value a2)

ex1 :: Val (Number,(Number,Number))
ex1 = T2 (P (N 3), T2 (x, P (N 5)))

-- ex2 :: Val (Number,Number)
-- ex2 = X

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


Re: [Haskell] [ANNOUNCE]: Ranged Sets

2005-12-12 Thread Tomasz Zielonka
On Sun, Dec 11, 2005 at 11:14:46PM +, Paul Johnson wrote:
> From the README:
> 
>Ranged sets allow programming with sets of values that are described 
> by a
>list of ranges.  A value is a member of the set if it lies within one of
>the ranges.  The ranges in a set are ordered and non-overlapping, so the
>standard set operations can be implemented by merge algorithms in 
> O(n) time.

I was thinking about writing such a library myself. Now I won't have to
:-)

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Can anyone help me with partition numbers?

2005-11-25 Thread Tomasz Zielonka
On Thu, Nov 24, 2005 at 05:52:23PM +0100, Jan van Eijck wrote:
> Like so: 
> 
> generatePs :: (Int,[Int]) -> [[Int]] 
> generatePs (n,[])   = [take n (repeat 1)]
> generatePs (n,(x:xs))   = 
>   (take n (repeat 1) ++ (x:xs)) : generatePs (pack (x-1) ((n+x),xs))
>   where 
>   pack :: Int -> (Int,[Int]) ->(Int,[Int])
>   pack 1 (m,xs) = (m,xs)
>   pack k (m,xs) = if k > m  then pack (k-1) (m,xs) 
>   else   pack k (m-k,k:xs)
> 
> parts :: Int -> [[Int]] 
> parts n | n < 1 = error "part: argument <= 0"
> | n == 1= [[1]]
> | otherwise = generatePs (0,[n])

How about a shorter version?

part :: Integer -> [[Integer]]
part = gen 1
  where
gen m 0 = [[]]
gen m n = [ x:xs | x <- [m..n], xs <- gen x (n - x) ]

Best regards
Tomasz

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


Re: [Haskell] ANNOUNCE: Frag: a First Person Shooting game

2005-11-21 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 05:05:17PM +1100, Mun Hon Cheong wrote:
> Frag is a 3D First Person Shooting game.

I would be nice if you could put some screenshots somewhere.

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


Re: Records (was Re: [Haskell] Improvements to GHC)

2005-11-20 Thread Tomasz Zielonka
On Sun, Nov 20, 2005 at 02:09:04PM -0500, David Roundy wrote:
> > [x,y,z]
> [...]
> > R { field1 = x, field2 = y, field3 = z }
> > 
> > I think this is very consistent.
> 
> I see, you're right that it's consistent, but I still don't like the use of
> '=' in this scenario.

I understand you. I had the same feelings some time ago, I even have
them today to some degree. At least consistency helps to get used to it.

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


Re: Records (was Re: [Haskell] Improvements to GHC)

2005-11-20 Thread Tomasz Zielonka
On Sun, Nov 20, 2005 at 08:54:35AM -0500, David Roundy wrote:
> As an aside, what's responsible for the insanity of pattern matching record
> fields being backwards? I'd bar = b to bind b to bar, not the other way
> around... why should record pattern matching use '=' in a manner opposite
> from the rest of Haskell?

It just mimics the way (record) values are constructed, as in all
pattern matching in Haskell. You can put a pattern variable everywhere
you could put a value in a corresponding constructing expression. For
example, all these "terms" can be used both as an expression and a
pattern. In the first case x, y, z are expressions, in the second they
are patterns.

[x,y,z]

(x:y:z)

(x,(y,z))

(C x y, D z)

R { field1 = x, field2 = y, field3 = z }

I think this is very consistent.

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


Re: [Haskell] Making Haskell more open

2005-11-13 Thread Tomasz Zielonka
On Sun, Nov 13, 2005 at 09:11:46PM +0100, Wolfgang Jeltsch wrote:
> Which browser are you speaking about?  I use Konqueror.

I don't know about Konqueror, but in Firefox you can quickly increase
or decrease the font size pressing Ctrl with + or -. This is a local
per-window, per-tab setting, so it doesn't affect how other pages
look.

BTW, I don't care if you make fonts on haskell.org bigger - after all
I can always press Ctrl and - ;-)

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


Re: [Haskell] Haskell based web server?

2005-11-13 Thread Tomasz Zielonka
On Sat, Nov 12, 2005 at 01:10:03PM -0800, Gregory Woodhouse wrote:
> am interested  (among other things) in the possibilities of using
> Haskell to develop  safety critical systems.

I think it will be interesting for you that Galois, one of the top
Haskell companies, makes money on safety critical systems.

http://www.galois.com/

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


Re: [Haskell] Haskell based web server?

2005-11-13 Thread Tomasz Zielonka
On Sat, Nov 12, 2005 at 01:10:03PM -0800, Gregory Woodhouse wrote:
> I've been reading the article "Tackling the Awkward Squad" by Simon  
> Peyton Jones (and find it very readable and useful, BTW). I wonder if  
> the HTTP/1.1 server referred to in this article is available on the  
> web.

I think you can get it from the fptools CVS repository. You will
find instructions on the GHC site - http://www.haskell.org/ghc/.

It's pretty old and because it uses non-standard extensions, you may
have some problems with newer versions of GHC. If you do, try with
hws-wp (http://www.mdstud.chalmers.se/~md9ms/hws-wp/).

> If not, where else can I look for examples of TCP/IP based  
> server applications written in Haskell?

HTTP client library written in Haskell:
http://www.haskell.org/http/
A chat client written in Haskell:
http://repetae.net/john/computer/ginsu/

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


Re: [Haskell] Haskell based web server?

2005-11-12 Thread Tomasz Zielonka
On Sat, Nov 12, 2005 at 01:10:03PM -0800, Gregory Woodhouse wrote:
> I ask because I'm very much a  Haskell newbie, but have spent several
> years developing interfaces  for medical information systems based on
> HL7, and am interested  (among other things) in the possibilities of
> using Haskell to develop  safety critical systems.

You may find this entertaining... or not:
http://www.haskell.org/humor/saveslives.html
;-)

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


Re: [Haskell] Making Haskell more open

2005-11-11 Thread Tomasz Zielonka
On Fri, Nov 11, 2005 at 05:00:52PM +0100, Tomasz Zielonka wrote:
> How about an integrated newsgroup+mailinglist+forum. If we had a
> two-way newsgroup+mailinglist integration, people could use it also
> as a forum, for example through gmail.google.com.

Of course I meant groups.google.com

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


Re: [Haskell] Making Haskell more open

2005-11-11 Thread Tomasz Zielonka
On Fri, Nov 11, 2005 at 04:52:30PM +0100, Wolfgang Jeltsch wrote:
> IMO, the best solution are newsgroups.  What I dislike with web-based 
> communication (webmail, webforums) is that webbrowsing is not as flexible as 
> using a specialized software and that you are not free in choosing your 
> communication software apart from choosing a webbrowser ??? you have to live 
> with the webmail/webforum software installed on the server, independently of 
> whether you like it or not.

That's a good point... or points. I also like newsgroups, but I haven't
used them in a while, probably because most of discussions about haskell
take place on mailing lists.

Maybe it's time to register comp.lang.haskell?

Could someone tell me something about fa.haskell? Is it a mirror of
[EMAIL PROTECTED] Can it be used to post messages through NNTP?

> > How about a forum integrated with mailing lists?
> 
> Does such a thing already exist somewhere?

Not that I know of.

How about an integrated newsgroup+mailinglist+forum. If we had a
two-way newsgroup+mailinglist integration, people could use it also
as a forum, for example through gmail.google.com. But I don't use
fora, so I probably talk nonsense.

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


Re: [Haskell] Re: Making Haskell more open

2005-11-11 Thread Tomasz Zielonka
On Fri, Nov 11, 2005 at 03:19:27PM +, Duncan Coutts wrote:
> > I cannot imagine that a couple of people is sufficient to review all recent 
> > changes and therefore I don't think they do it this way.  There are some 
> > typical articles where screwing up happens often, so these articles might 
> > be 
> > regularily revisited.  Screwing up of articles might as well be removed by 
> > ordinary people who discover ugly things in articles by accident.
> 
> One possability here would be to have all changes to the wiki reported
> in real time (or near real time) in the #haskell IRC channel. The
> #haskell lambdabot could be extended to do this.
> 
> The #haskell IRC channel is active nearly 24 hours a day and has a
> membership that varies between 170 and 200. This would easily be enough
> eyes to spot malicious or inaccurate changes.

I think that the amount of changes that need to be reviewed could be
dramatically reduced if we create some trust management system, for
example we could trust changes made by authorized users. The users
who most often contribute to the Wiki will probably be the same who care
about reviewing changes and they probably won't mind to log in, so their
changes won't have to be reviewed.

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


Re: [Haskell] Making Haskell more open

2005-11-11 Thread Tomasz Zielonka
On Fri, Nov 11, 2005 at 03:12:40PM +, Duncan Coutts wrote:
> I would tend to disagree. I think the combination of the mailing lists,
> a wiki and the IRC channel cover most of our communication needs.

Personally I prefer to use mailing lists, but they have one disadvantage
- if you don't set up filters to split incoming mail into multiple
folders, you can be flooded with messages.
 
> I don't think that yet another variant would help us much. Web boards
> tend to be harder to use than email since it requires a web browser.
> Having too many differnt types of communication channel would reduce the
> readership of any one of them.

How about a forum integrated with mailing lists?

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


Re: [Haskell] [ANNOUNCE] yhc - York Haskell Compiler

2005-11-11 Thread Tomasz Zielonka
On Fri, Nov 11, 2005 at 12:24:49PM +, Neil Mitchell wrote:
> - It's very much work in progress, indeed the source code in the darcs
> repository as of today is currently somewhat disfunctional as is in
> between changes (hence why the Makefile is broken).

It may be a good idea to have yhc-stable and yhc-devel repositories,
where yhc-stable should be functional most of the time. That's how
darcs' repos are organized.

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


Re: [Haskell] why I need so much memory????

2005-11-09 Thread Tomasz Zielonka
On Tue, Nov 08, 2005 at 06:40:36PM +0100, Alberto Fuentes Rodriguez wrote:
> Each card is represented with a Char (to make the structure smaller) and 
> then all the hands are a [[Char]]
> in total the structure has a size of arround 20Mb.
> 
> Ok the complexity is high but why this program needs 1GB (the structure 
> only has 20MB) of memory??

Perhaps the structers *does* take 1GB, but till now the program didn't
require it all in memory at once because of lazy evaluation and GC.

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


Re: [Haskell] Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 01:02:19PM +0100, Wolfgang Jeltsch wrote:
> Only 2% find fglasgow-exts useful???

Only 2% consider it a tool or library.

I think that if John cares about getting reliable results, he should
take the results from this survey and prepare the next one already
having all the most important options. I won't mind filling the new
survey again, because I myself find the results interesting. I
wonder what other people think?

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


Re: [Haskell] Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 12:58:22PM +0100, Wolfgang Jeltsch wrote:
> why doesn't the section about Haskell tools and libraries mention HToolkit?

This section is auto-extending. If you enter HToolkit in the textarea
below and submit, HToolkit will be added to the list.

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


Re: [Haskell] WASH-Problem was Re: Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 11:40:13AM +0100, John Hughes wrote:
> I'm afraid not, because there's no record of which is YOUR entry. I 
> suppose I could have asked for an email address, but not everybody likes 
> to supply that, so I thought it better to keep the whole thing 
> anonymous. (Not to worry, Parsec is getting a lot of votes anyway!)

I am the only one from Poland so far ;-) I would also add darcs.
But OK, I don't suppose you like the idea of manually fixing entries.

It would be nice to repeat this survey in a year or so with a long list
of tools (which you'll gather this time), so people are less likely to
forget what they use.

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


Re: [Haskell] WASH-Problem was Re: Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 11:21:02AM +0100, Christian Maeder wrote:
> I've no idea and could not reproduce the bug. Our program is at 
> http://www.informatik.uni-bremen.de/cgi-bin/cgiwrap/luettich/hets.cgi
> 
> Enter i.e "sort s" or "spec S = {}" as specification.

I did and I saw a screen with a reference to the Hets Manual, but
no other links, buttons, etc.

> The tools list is extended automatically, after a response? There is an 
> odd entry "Parsec, HOpenGL"

Someone hasn't read the instructions :-)

BTW, is there a way to update my entry? I forgot to mention one of the
best tools I use - Parsec :-(

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


Re: [Haskell] Re: Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 11:02:04AM +0100, John Hughes wrote:
> Thank you, that explains it. A WASH subtlety, caused by using unsafe IO 
> to read the tools and country lists. Should now be fixed!

Ah, right, so the program doesn't change, only its data.

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


Re: [Haskell] Re: Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 04:55:46AM -0500, Cale Gibbard wrote:
> It seems that if you keep trying to fill out the form, you will
> eventually succeed. If someone finishes filling out the form between
> when you start filling it out and when you finish, then the
> checkboxes/dropdowns will have been updated, and you'll have to reload
> the page and try again. Certainly a bug.

Yes, John used a nice trick to automatically extend the option lists,
but it breaks the assumptions of WASH. He should ensure that each user
uses the same version of the script.

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


Re: [Haskell] WASH-Problem was Re: Haskell users survey--please respond!

2005-11-09 Thread Tomasz Zielonka
On Wed, Nov 09, 2005 at 10:52:51AM +0100, Christian Maeder wrote:
> Aaron Denney wrote:
> >I hit "Submit response and view previous responses" and it says
> >"Unspecified action" and a "Try again..." hyperlink.
> 
> I have the same problem even with our own cgi-program based on WASH and 
> ghc-6.4.1

Does it happen when you modify the cgi-program in the middle of a
session? This is the biggest problem with WASH - to be able to rebuild
the state from session log it needs the program structure to be
constant. I work around it by copying the current cgi-program at the
start of session, so each session sees only one version of cgi-program.

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


Re: [Haskell] Literal for Infinity

2005-09-29 Thread Tomasz Zielonka
On 9/29/05, Yitzchak Gale <[EMAIL PROTECTED]> wrote:
While checking for floating-point overflow andunderflow conditions, I tried to create a somewhatreliable cross-platform Infinity with the literal"1e10".When GHC 6.4.1 reads this literal, it goes into a
deep trance and consumes huge amounts ofmemory. Shouldn't it immediately recognize such athing as Infinity?
I think it is equivalent to (fromRational 1e10), and (1e10 :: Rational)
can take a substantial amount of space. 

Is there a better way to check for Infinity?  Ihave not yet figured out how to check for NaN at
all - because it is not equal to itself. Anysuggestions?
Did you try isNaN and isInfinite? I don't have much experience with these functions myself.
Best regards
Tomasz

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


[Haskell] Re: ANNOUNCE: GHC version 6.4.1

2005-09-22 Thread Tomasz Zielonka
On 9/19/05, Simon Marlow <[EMAIL PROTECTED]> wrote:
The GHC Team is pleased to announce a new patchlevel release of GHC.This release contains a significant number of bugfixes relative to6.4, so we recommend upgrading.  No library APIs have changed, so codethat was working with 
6.4 should continue to work with 6.4.1.
Good job! The program I was working on today runs 24% faster with 6.4.1 compared to 6.4 :-)

Best regards
Tomasz

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


Re: [Haskell] Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Tomasz Zielonka
On Fri, Sep 16, 2005 at 02:37:14PM -0700, Michael Vanier wrote:
> But were they as efficient?

If some code is equivalent to macro expansion then the compiler should
be able to optimize it to the same extent as a macro.

> The beauty of macros is that a lot of things can be done with no
> run-time overhead at all.

Macros can lead to bigger generated code size, which can affect
performance.

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


Re: [Haskell] Re: [Haskell-cafe] Haskell versus Lisp

2005-09-16 Thread Tomasz Zielonka
On Fri, Sep 16, 2005 at 05:40:04PM +0100, Glynn Clements wrote:
> 
> Every other language (including Haskell) tends to have the problem
> that eventually you will encounter a situation where the language's
> own worldview gets in the way.

Are you sure that lisp's worldview never gets in the way?

> Or, to put it another way: if Haskell is so flexible, why do we need
> Template Haskell?

It's nice to have Template Haskell, but saying that we need it is a bit
of an overstatement. In the GHC Survey 2005 only 9% of people said it's
essential. Well, OK, I was one of them, but I think you know what I
mean.

> I can't imagine a "Template Lisp"; it would just be Lisp.

The power of lisp macros is often overrated. I remember a long
discussion crossposted on comp.lang.lisp an comp.lang.functional. The
lisp advocates gave examples for how macros allow to do things
supposedly unavailable in other languages. Surprisingly, most of these
things were equally easy to do with higher-order functions and closures
in Haskell.

I am sure that lisp gurus can achieve great things with macros, but I'm
not sure they are the best tool for software engineering problems.
I think they can make the code more difficult to understand, make the
semantics less uniform (despite the uniform syntax), and can become an
abused ugly hack.

Don't get me wrong - I still think that lisp is one of the best
programming languages around and from time to time I am trying to learn
a bit of it.  One of the things that puts me off is the attitude of its
community - it seems to be very close minded.

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


Re: [Haskell] Re: Mixing monadic and non-monadic functions

2005-09-16 Thread Tomasz Zielonka
On Sun, Sep 11, 2005 at 01:48:16AM -0400, Cale Gibbard wrote:
> On 10/09/05, Frederik Eaton <[EMAIL PROTECTED]> wrote:
> > These are good arguments, and I think this is a good direction for the
> > discussion, should it continue.
> > 
> > > Despite having a fairly mathematical background, I don't really care
> > > for the proposed syntax.
> > >
> > > myList :: [[Integer]]
> > > myList = return [1,2,3,4]
> > 
> > I'm assuming you mean
> > 
> > myList :: [[Integer]]
> > myList = [1,2,3,4]
> 
> No, the confusion is over whether to lift the return, because the
> inner and outer monads are the same. It's either return [1,2,3,4] ==
> [[1,2,3,4]], or it's liftM return [1,2,3,4] == [[1],[2],[3],[4]]

I think that Frederik's example is even better. Here you either lift the
entire list or each individual number:

return [1,2,3,4]

or

[return 1,return 2,return 3,return 4]

After all, return is only a fancy name for liftM0 ;-)

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


Re: [Haskell] mailing list headaches

2005-09-08 Thread Tomasz Zielonka
On Thu, Sep 08, 2005 at 12:29:19AM -0700, Frederik Eaton wrote:
> I don't expect that this hackery will be very useful to you, but I've
> posted it here so you can see:
> 
> http://ofb.net/~frederik/mailproc.tar.gz

Thanks! Hopefully it will be at least an inspiration to improve my
mail config :-)

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


Re: [Haskell] mailing list headaches

2005-09-07 Thread Tomasz Zielonka
On Wed, Sep 07, 2005 at 12:46:42PM -0700, Frederik Eaton wrote:
> Hi all,

Hi!

> After some weeks of squinting, I've ended up settling with the
> following partial solution in my configuration files (I use Mutt):
> 
> set strict_threads=yes
> folder-hook folders/haskell set strict_threads=no
> folder-hook folders/libraries set strict_threads=no
> folder-hook folders/glasgow-haskell set strict_threads=no
> folder-hook folders/glasgow-haskell-bugs set strict_threads=no

Nice, thanks! BTW, could you also share the configuration you use to
split e-mails into folders? Do you use procmail for this?

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


Re: [Haskell] do notation and type synonym

2005-08-07 Thread Tomasz Zielonka
On Sun, Aug 07, 2005 at 08:26:07PM +0200, mt wrote:
> the first check5 is ok and return Nothing while the second check5' will raise 
> an "Exception: Non-exhaustive patterns" (which is what i've expected).
> 
> the sentence "there is nothing magic with do" with its reason are important 
> for me to understand monads and do notation, so maybe someone can rephrase 
> "there is nothing magic with do" and explain the exposed behavior?

The actual translation is a bit more complex to deal with (surprise!)
pattern-match failures, like in your code. See the third equation in the
"Translation" border on this page:
http://www.haskell.org/onlinereport/exps.html#sect3.14
Still no magic.

> second one:
> is it possible to write something like
> type Point = (Float, Float)
> type Vector = (Float, Float)
> and still have type safety (i.e. not be able to mix Point and Vector) (and 
> still have (*,*) without constructor)?

I think it's not possible in current Haskell. If tuples were somehow
overloaded, as numbers are...

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


Re: [Haskell] Files and lazyness

2005-08-01 Thread Tomasz Zielonka
On Thu, Jul 28, 2005 at 08:01:17PM +0200, Diego y tal wrote:
> I understand that this is caused by the lazyness,

No, it is caused by mixing laziness with side-effects, which happens
when you use getContents/readFile.

> that doesn't evaluate the expression "x <- readFile fEntrada" until
> it's necessary,

"x <- readFile fEntrada" is not an expression.

> but.. is it normal that we have to think about this "problem" when
> programming?

You just have to know, which functions mix laziness and side-effects
by using unsafeInterleaveIO (readFile, getContents, hGetContents).

> I find this a great disadvantage as oppose of the imperative paradigm,

I wouldn't say this is a great disadvantage of Haskell, because:
a) the imperative paradigm is available in Haskell
b) readFile is a bit of hack, because it uses laziness where the order
   of execution matters (it uses unsafeInterleaveIO). It is generally
   known that readFile should be used only for the simplest I/O tasks.
c) there are other ways to complete the task (however, some of them
   are non-standard)

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


Re: [Haskell] offside rule question

2005-07-15 Thread Tomasz Zielonka
On Fri, Jul 15, 2005 at 09:10:16AM +0100, Axel Simon wrote:
> I agree with Frederik since I've been bitten by that rule before.
> Defining a single function like so:
> 
> let a very long definition of "a" = and the body has to be here 
> is a very long application to
> "and" and using long arguments
> like definition is a pain
> in
> 
> 
> is harder to read and might force you to use shorter, less descriptive
> variable names.

But you can format it this way:

let a very long definition of "a" =
and the body has to be here is a very long application to "and"
but using long arguments like definition is not that bad
in

or this way:

let 
  a very long definition of "a" =
and the body has to be here is a very long application to "and" but
using long arguments like definition is not that bad
in

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


Re: [Haskell] Template id function

2005-07-13 Thread Tomasz Zielonka
On Wed, Jul 13, 2005 at 08:50:21PM +0200, Mads Lindstr?m wrote:
> I am trying to learn Meta Haskell. One thing I want to do is create an
> identity function. It should get a type constructor as input and return
> the same type constructor as output. It should be possible to do:
> 
>   $(idDecl data Foo = Foo Int)
> 
> and it should "return":
> 
>   data Foo = Foo Int
> 
> Is this possible? if yes, how does one do it?

You mean:

$(id [d| data Foo = Foo Int |])

?

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


Re: [Haskell] line-based interactive program

2005-07-09 Thread Tomasz Zielonka
On Fri, Jul 08, 2005 at 09:55:48PM +0200, Wolfgang Jeltsch wrote:
> As part of my diploma thesis, I'm working on a small collection of modules 
> which provides safe I/O interleaving.  The key point is to split the state of 
> the world since I/O on different parts of the world can be interleaved 
> arbitrarily.  If someone is interested, I can post more details.

Is it something similar to Clean's approach to IO?

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


Re: [Haskell] Rank-N types vs existential types

2005-04-27 Thread Tomasz Zielonka
On Wed, Apr 27, 2005 at 09:16:16PM +1000, Andre Pang wrote:
> >data RankN  = RankNEq (forall a. Eq a => a -> a -> Bool)
> >| RankNOrd (forall a. Ord a => a -> a -> Bool)
> >
> >data Exists = forall a. Eq a => ExistsEq (a -> a -> Bool)
> >| forall a. Ord a => ExistsOrd (a -> a -> Bool)
> 
> The two seem pretty equivalent to me, since the data 
> constructors have the same type.

They don't:

ExistsEq :: (Eq a) => (a -> a -> Bool) -> Exists
RankNEq :: (forall a. (Eq a) => a -> a -> Bool) -> RankN

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


Re: [Haskell] Read and write file on Windows XP.

2005-04-24 Thread Tomasz Zielonka
On Sun, Apr 24, 2005 at 06:01:34PM +0200, Alexandre Weffort Thenorio wrote:
> outputLine keyno key orgFile = do
> -- Some code that modifies
> second line here
> newHexFile <- openFile
> "newint.hex" WriteMode
>  hPutStrLn newHexFile
> (orgFile!!0 ++ "\n" ++ final ++ unlines (drop 2 orgFile))
> 
> What happens is everything works fine on my PC (Windows 2000) but on another
> PC (Using Windows XP) it sometimes gives a file which is incomplete, a
> couple of lines missing in the end making the file smaller and wrong.

Maybe try hClose'ing the newHexFile at the end of outputLine...?

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


Re: [Haskell] HCAR?

2005-04-14 Thread Tomasz Zielonka
On Thu, Apr 14, 2005 at 11:24:24AM +0200, Tomasz Zielonka wrote:
> On Thu, Apr 14, 2005 at 01:54:15AM -0700, Ashley Yakeley wrote:
> > Was there a call for HCAR contributions on this list? Did I miss it?
> 
> The last one I can find in my mail archives was on Nov 10, 2004.

I've got the new announce now.

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


Re: [Haskell] HCAR?

2005-04-14 Thread Tomasz Zielonka
On Thu, Apr 14, 2005 at 01:54:15AM -0700, Ashley Yakeley wrote:
> Was there a call for HCAR contributions on this list? Did I miss it?

The last one I can find in my mail archives was on Nov 10, 2004.

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


Re: [Haskell] Data.Map missing keysFM_GE, eltsFM_GE?

2005-02-21 Thread Tomasz Zielonka
On Mon, Feb 21, 2005 at 02:39:54PM -0500, S. Alexander Jacobson wrote:
> Data.FiniteMap has functions keysFM_GE and eltsFM_GE which return the 
> keys or elts of pairs greater than or equal to the provided key.
> 
> These functions do not appear to be in the new Data.Map.
> 
> Is this intentional?

There is

splitLookup :: (Ord k) =>
   k
   -> Data.Map.Map k a
   -> (Data.Map.Map k a, Maybe a, Data.Map.Map k a)

and

toAscList :: Data.Map.Map k a -> [(k, a)]

so you can write keysFM_GE and eltsFM_GE yourself, for example:

  eltsFM_GE k m = maybe [] return eq ++ Prelude.map snd (toAscList ge)
where
  (_, eq, ge) = splitLookup k m in 

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


Re: [Haskell] Re: help with some basic code that doesn't work

2005-02-14 Thread Tomasz Zielonka
On Mon, Feb 14, 2005 at 12:36:22PM +0100, Remi Turk wrote:
> > Now that this topic is brought up...
> > 
> > Occasionally I would need to define recursive datatypes
> > using an explicit fixed-point operator, such as:
> > 
> > > data Fix f = In (f (Fix f))  deriving (Show, Eq)
> > > data L a x = Nil | Cons a x  deriving (Show, Eq)
> > 
> > However, Haskell was not able to  derive from Fix f any
> > instances.
> >
> [snip]
> > 
> > This is rather unsatisfactory, because I would not be able
> > to inspect values of type Fix f in the interpreter. Is there
> > a way to get around this?
> 
> Funny this comes up at this time, as Fix was on-topic yesterday
> at #haskell. One way to make Fix an instance of Show/Eq is this
> (based on http://www.haskell.org/hawiki/PreludeExts, where Fix is
> called Rec):

It's even more funny - just yesterday I wanted to derive Show and Read
for a similar datatype :)

Best regards
Tomasz

-- 
Szukamy programisty C++ i Haskell'a: http://tinyurl.com/5mw4e
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Typing in haskell and mathematics

2005-01-28 Thread Tomasz Zielonka
On Fri, Jan 28, 2005 at 10:01:33AM -0500, Jacques Carette wrote:
> The previous post on record syntax reminded me of some 'problems' I had 
> noticed where Haskell and mathematics have a (deep) usage mismatch.
> 
> First, consider a syntax for other component-wise function application?  
> For example, it would be convenient to have (f,g) @ (x,y)
> be (f x, g y).  In some languages [with dynamic typing], one can even do 
> (f,g) (x,y) :-)  
> Yes, I am aware that this untypeable in Haskell, because polymorphism is 
> straight-jacketed by structural rules.

It's not as bad as you think. You can do this:

{-# OPTIONS -fglasgow-exts #-}

module Apply where

class Apply f a b | f -> a, f -> b where
apply :: f -> a -> b

instance Apply (a -> b) a b where
apply f a = f a

instance Apply (a1 -> b1, a2 -> b2) (a1, a2) (b1, b2) where
apply (f1, f2) (a1, a2) = (f1 a1, f2 a2)

instance Apply (a1 -> b1, a2 -> b2, a3 -> b3) (a1, a2, a3) (b1, b2, b3) 
where
apply (f1, f2, f3) (a1, a2, a3) = (f1 a1, f2 a2, f3 a3)

And then:

*Apply> (succ, pred, show) `apply` (1, 2, ())
(2,1,"()")

*Apply> (\x -> 2 * x + 1/2, length) `apply` (10, [1,2,3,4,5])
(20.5,5)

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Why is getArgs in the IO monad?

2005-01-18 Thread Tomasz Zielonka
On Tue, Jan 18, 2005 at 08:12:42AM -0800, Ben Rudiak-Gould wrote:
> Even if you want to disallow explicit recompilation (and how do you define
> "compilation" denotationally?), an automatic rollout of a new version of Hugs
> could lead to successive invocations of a script using different values of
> (maxBound :: Char) (or, more plausibly, some constant defined in the library)
> without user intervention. How is this different from any other environmental
> change, such as a change in the program arguments?

Big difference. The change in program arguments is inevitable, or at least
expected. The change in Haskell implementation can be avoided, by compiling
the program or simply by not switching to a newer version.

The more there are pure values that change from execution to execution,
the more often will smart libraries like WASH/CGI break in mysterious
ways. Please, no!

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Why is getArgs in the IO monad?

2005-01-18 Thread Tomasz Zielonka
On Tue, Jan 18, 2005 at 01:31:19AM -0500, Jim Apple wrote:
> Tomasz Zielonka wrote:
> 
> >I like to think that pure functions don't change between executions.
> 
> I'd like to think they wouldn't change within executions. Is there a 
> pure haskell way to check the value of a function between exections?

Perhaps I was unclear. I want pure functions to give the same results every
time they are run for the same arguments, as long as the have the same
definition. This makes like easier. Also, some haskell libraries rely on that
- take WASH/CGI for example.

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Why is getArgs in the IO monad?

2005-01-17 Thread Tomasz Zielonka
On Mon, Jan 17, 2005 at 04:23:17PM -0500, Jim Apple wrote:
> See subject. It seems that it would be constant through execution, and 
> so could be just [String].

I like to think that pure functions don't change between executions.
getArgs :: [String] would certainly break that.

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Context of a pattern variable

2005-01-12 Thread Tomasz Zielonka
On Wed, Jan 12, 2005 at 11:47:51AM +, Malcolm Wallace wrote:
> Malcolm Wallace <[EMAIL PROTECTED]> writes:
> 
> > Marcus Mohnen, "Context Patterns", Proceedings of IFL'96 (LNCS 1268)
> > Marcus Mohnen, "Context Patterns II", Proceedings of IFL'97 (LNCS 1467)
> 
> There is a web page too, with an implementation of context patterns
> for an old (2.01) version of ghc:
> 
> http://www-i2.informatik.rwth-aachen.de/Staff/Current/mohnen/CP/index.html

Wow, this gives much more than my proposal. 

Actually, it seems to be a similar, but different idea. Mohnen's patterns must
(AFAICS) be compiled to a pattern _search_ algorithm, while "mine" can be
implemented with very simple code transformation. 

Also, I am not sure what this expressions should evaluate to:

case ([1], [2]) of
(c [x]) -> c []

Will it be ([], [2]) or ([1], []) ? Perhaps I should just RTFP (Read
The Fine Paper).

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


Re: [Haskell] Re: Context of a pattern variable

2005-01-12 Thread Tomasz Zielonka
On Tue, Jan 11, 2005 at 10:12:06PM -0500, [EMAIL PROTECTED] wrote:
> Tomasz Zielonka <[EMAIL PROTECTED]>
> proposed an interesting kind of ``second-order as-patterns''
> that are ``safe'' from the usual problems of second-order matching
> by virtue of fixing (at least) the spine
> of the images of the second-order variables.

So it is a known idea?

> This could be alleviated by making the character of the intended binding
> as a second-order binding more explicit
> by allowing as-patterns to bind against function left-hand sides,
> where variables occurring in patterns may be ``co-bound''
> in the pattern part of the as-pattern
> by a SINGLE occurrence of the ``co-as''
> for which I continue to use Tomasz' symbol ``@>''.
> 
> The first example would then be written:
> 
>case t of
>   (ctx zH) @ (_, _, zH @> z) -> ctx (z + 1)

Probably I get something wrong, but couldn't we simply write it this way?

  case t of
  (ctx z) @ (_, _, z) -> ctx (z + 1)

That is - completely forget about @> ?

Anyway, I like your notation very much. Mine was a bit clumsy.

> The first occurrence of zH is a binding occurrence,
> and the second occurrence is co-bound by the ``@>''.
> (Replacing ``@>'' with ``@'' could give rise to confusing errors,
>  no matter which way the binding of its left argument is resolved.)

Could you give an example?

> The first version of Tomasz' counterexample
> is treated in the same way as the first example:
> 
>   case t of
> (ctx zH) @ (x, y, (a, zH @> Just z)) -> ctx z
> 
> The expression corresponding to the ``broken'' context
> then exhibits a composed context:
> 
>   case t of
> (ctx1 vH) @ (x, y, vH @> v) ->
> case v of
>(ctx2 zH) @ (a, zH @> Just z) -> ctx1 (ctx2 z)

Nice. So we could also collapse the case expressions, nesting the
second-order patterns?:

  case t of
(ctx1 vH) @ (x, y, vH @> (ctx2 zH) @ (a, zH @> Just z)) -> ctx1 (ctx2 z)

> I think that this way we have the concepts right ---
> how useful this feature would be
> is probably going to be mostly a question of programming style.
> For very deep pattern matching in, for example, XSLT-like applications
> it could probably be quite convenient.

I wonder if this idea could be nicely combined with HaRP - Haskell Regular
Patterns...

Thanks for your insightful and enlightening comment!

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: Context of a pattern variable [ERRATA]

2005-01-11 Thread Tomasz Zielonka
Below are corrections of embarassing mistakes in my examples, pointed out by
Wolfram and Stefan Holdermans.

On Tue, Jan 11, 2005 at 11:12:04PM +0100, Tomasz Zielonka wrote:
> before:
> 
>   case t of
>   (x, y, z) -> (x, y, z+1)
> 
> after:
> 
>   case t of
>   (_, _, ctx @> z) -> ctx z

(_, _, ctx @> z) -> ctx (z+1)

> BTW, I already see some problems with this syntax. For example, this code
> 
>   case t of
>   (x, y, (a, ctx @> Just z)) -> ctx z
> 
> wouldn't be equivalent to this one
> 
>   case t of
>   (x, y, v) -> 
>   case v of 
>   ctx @> Just z -> ctx z

(a, ctx @> Just z) -> ctx z

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Context of a pattern variable

2005-01-11 Thread Tomasz Zielonka
On Wed, Jan 12, 2005 at 01:02:43AM +0100, Stefan Holdermans wrote:
> Furthermore, I think with this syntax,  it is just too easy to get 
> wrong. Maybe I'm mistaken, but, to illustrate, I believe there's even 
> an error in the very examples given by you:
> 
> >after:
> >
> >  case t of
> >  (_, _, ctx @> z) -> ctx z
> 
> Shouldn't that be  case t of (_, _, ctx @> z) -> ctx (z + 1)?

Yes, it should.

I didn't have much time to think about this idea, so I thought I will pass it
on to other people with more time and/or brains before I completely forget it.

As for the bug, let me give you more data points to consider. At the time I
was writing the examples I was simultaneously distracted by my wife (accusing
me of being a computer-o-holic ;) and my cat (wanting me to play with her).
I think it was a bigger "contribution" to this bug :)

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Context of a pattern variable

2005-01-11 Thread Tomasz Zielonka
On Tue, Jan 11, 2005 at 06:30:02PM -0500, Stefan Monnier wrote:
> >   case t of
> >   (x, y, z) -> (x, y, z+1)
> 
> How would you do:
> 
> case t of
> (x, y, z, a, b, c) -> (x+1, y, z, a, b, c+2)
> 
> would you allow:
> 
> case t of
> (ctx @> x, _, _, _, _, ctx @> c) -> ctx (x+1) (c+2)

I thought about it, but not too much. Wolfram's idea seems nice.

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Context of a pattern variable

2005-01-11 Thread Tomasz Zielonka
Hello!

I have an idea for a funny extension to pattern matching in Haskell. I wonder
if it was proposed before, and most importantly, if it would be seen as useful.

Currently, pattern variables get only the values of the corresponding subterms
of a matched term. What if we could mark a pattern variable to match not the
corresponding subterm, but *the rest* of the term, as a "context" function.
Such a function would wrap its argument with *the rest*. It would allow to
easily exchange some deep part of a data structure.

The extension introduces a new syntax for patterns, similar to the as-pattern -
@. In the following examples, I'll use @> for this. The syntax

case expr of
(... (ctx @> pat) ...) -> expr2
...

would mean that if the pattern succeeds, then in expr2 ctx is bound to the
function:

(\x -> (... (x) ...))

This is very informal, but I'm sure you understand. Note that the dots stand
for corresponding, but different things in "case" and in the lambda (pattern
 vs value).

Here are some simple examples how Haskell code could be rewritten using the
proposed extension:

before:

  case t of
  (x, y, z) -> (x, y, z+1)

after:

  case t of
  (_, _, ctx @> z) -> ctx z

before:

  case t of
  (x, y, (a, Just z)) -> (x, y, (a, z))

after:

  case t of
  (x, y, (a, ctx @> Just z)) -> ctx z

Note that in the above example ctx is a polymorphic function.

I am not sure this extension would be so useful, that is, if its usefulness
would outweigh the cost of implementation. However, it seems to me that the
implementation would be quite a simple code transformation, that wouldn't
even require to look up datatype definitions. It is probably possible to hack a
working proof of concept eg. in Template Haskell.

BTW, I already see some problems with this syntax. For example, this code

  case t of
  (x, y, (a, ctx @> Just z)) -> ctx z

wouldn't be equivalent to this one

  case t of
  (x, y, v) -> 
  case v of 
  ctx @> Just z -> ctx z

I would love to hear you opinions. Maybe you can think of some really
convincing (or unconvincing) code examples?

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Fail <> ?

2005-01-07 Thread Tomasz Zielonka
On Fri, Jan 07, 2005 at 06:27:03PM -0500, Robert Dockins wrote:
> This means your program fails to terminate, and the runtime detected it
> (it can't always).  It is often caused by forgetting to code a base case
> in a recursive function, or by getting it wrong.  Without some code, it
> is hard to say more, but take a close look at all your recursive
> functions.

I would rather look at recursive "non-functions" (CAFs?), because that's where
GHC can sometimes detect nontermination (AFAIK).

I would expect things like these:

x = x
x = x + 1
fibs = 0 : zipWith (+) fibs (tail fibs) -- subtle bug, 0 : 1 : would work

Best regards,
Tomasz
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Force evaluation

2004-12-06 Thread Tomasz Zielonka
On Mon, Dec 06, 2004 at 10:24:06AM -0500, Michael Walter wrote:
> Hi,
> 
> is there a way to force the "full" evaluation of a value (unless seq,
> which only brings the term to WHNF)?
> 
> In my case, I have an algebraic data type Foo,
> and I would like to catch the exceptions that will occur during the
> evaluation of a value of Foo, for something like:
> 
>   foo <- force makeFoo `catch` \e -> defaultFoo

DeepSeq seems to be the most portable solution (can't tell you where to
find it). There is also module Strategies in package concurrent in GHC. I guess
you could also do something like deepSeq with Data.Generics.

Best regards,
Tomasz
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Better Exception Handling

2004-11-25 Thread Tomasz Zielonka
On Thu, Nov 25, 2004 at 07:52:43PM +0100, Lennart Augustsson wrote:
> As I'm sure you have gathered from all the answers you can't have the
> latter and keep Haskell pure.  But there is an interesting alternative
> (at least theoretically).  You could have a function like
> 
> mkCatchJust :: IO ((Exception -> Maybe b) -> (c -> a) -> c -> (b -> a) -> a)

How is that different from this?

  mkReadFile :: IO (FilePath -> String)

This is wrong. Even if I get a function as a result of an IO computation, I
expect that function to be pure.

> The cj function can be used in non-IO code and will behave just as you
> want.  But you have to create it in the IO monad, since it's behaviour
> is not deterministic (especially not in the face of async exceptions).

IO monad shouldn't be used to create non-deterministic functions. The whole
point in using IO monad is that functions stay pure, regardless of their
origin.

Best regards,
Tomasz
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Global Variables and IO initializers

2004-11-24 Thread Tomasz Zielonka
On Wed, Nov 24, 2004 at 08:53:47AM +0100, Lennart Augustsson wrote:
> Well, I don't.  unsafePerformIO is an extension that is very much
> against the spirit of Haskell.  Haskell with it does not have the
> properties I want.  So I don't use it. :)

I hope 'it' means unsafePerformIO, not Haskell :)

I agree. Without unsafePerformIO Haskell gives me many guarantees for free.
With unsafePerformIO, they are no longer for free, I have to think, prove,
etc. When I mistakenly give a pure function interface to an unpure
"function", it can affect my program in most unexpected places.

Best regards,
Tomasz
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Real life examples

2004-11-23 Thread Tomasz Zielonka
On Tue, Nov 23, 2004 at 08:50:45PM -0800, John Meacham wrote:
> Atom.hs from ginsu..
> 
> This is perhaps the best example, and an incredibly useful piece of code
> for anyone struggling with space problems out there.
> 
> it provides
> 
> data Atom = ... (abstract)
> 
> instance Ord Atom
> instance Eq Atom
> toAtom :: String  -> Atom
> fromAtom :: Atom -> String
> 
> [...]
>
> internally, Atom has a global hash table of strings -> atoms, note that
> externally, Atom is truly purely functional. toAtom and fromAtom
> although using internal state inside are real functions. the same
> argument always returns the same (externally visible) result. This is
> because the actual integer chosen is hidden, there is no way to get at
> it outside the module. 

Just a nitpick: will this code always yield the same results?

  map fromAtom $ sort $ map toAtom $ words "Just a nitpick"

Best regards,
Tom
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Parameterized Show

2004-11-15 Thread Tomasz Zielonka
On Mon, Nov 15, 2004 at 12:31:33PM +, Keean Schupke wrote:
> Easy:
> Here, with labelled instances you would write:
> 
>show ShowHex 27
> 
> instead you write:
> 
>show (ShowHex 27)

What about Ints buried deep in more complicated data structures:

show ShowHex [[1, 2, 3], [4]]

vs.

show (map (map ShowHex) [[1, 2, 3], [4]])

BTW, This thread reminds me a similar problem that was discussed on
haskell list. Unfortunately, there were some problems with this approach
(accumulating typeclass contexts).

  http://www.haskell.org/pipermail/haskell/2004-August/thread.html#14427

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Global Variables and IO initializers

2004-11-07 Thread Tomasz Zielonka
On Fri, Nov 05, 2004 at 07:03:06PM +, MR K P SCHUPKE wrote:
> >You don't want stdin/stdout/stderr?
> 
> Also these are only available in the IO monad...

No, they are available "outside" the IO monad, only you can't do
anything useful with them. Well, you can show them!

> >without breaking referential transparency
> >by use of unsafePerformIO hack.
> 
> I don't understand this still... how can it not break referntial transparancy.
> For example consider if stdin were available outside the IO monad.

If you could do interesting things with Handles "outside" the IO monad,
we would be doomed anyway.

Best regards,
Tomasz

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Monadic pretty-printing

2004-09-25 Thread Tomasz Zielonka
Hello!

In my master's thesis I am dealing with a complicated case of pretty
printing / unparsing. There are side effects, context dependency,
unparsing to two different languages (two SQL dialects). To manage
this complexity, I use a couple of ,,design patterns''.

One of them is about giving a monadic interface to pretty printing
library, to allow mixing it easily with various effects (IO, Reader,
Cont).

After some fiddling with a hand written pretty-printing monad, I
realized that I can just use a Writer monad. HughesPJ.Doc can be
trivially made an instance of Monoid - AFAIK all the needed laws hold.
The only problem is to decide which one of document composition
operators should be used as mappend. In my case I want <+> by default,
but I arranged things so that I can have several different versions of
Doc (newtyped).

As I needed many other pretty-printing combinators beside <+>/mappend,
I created a library of monadic pretty-printing combinators for
separating (eg. with commas), vertical composition, nesting, putting in
parentheses, <> composition, etc.  In some cases it was necessary to use
MonadWriter's "censor" method, but nothing more. I think it is quite
elegant.

The code written using this technique is also quite clear. Perhaps it
would be worse, if it wasn't possible to choose a composition operator
for Monoid doing the proper thing in 90% of cases. Below is a fragment
of code that handles expression unparsing.

unparse (Expr_BinaryOp op e1 e2) = parens $ do
unparse e1
unparse op
unparse e2

unparse (Expr_UnaryOp UnaryOp_Not (Expr_IsNull e)) = parens $ do
unparse e
kw IS
kw NOT
kw NULL

unparse (Expr_UnaryOp op e) = parens $ do
unparse op
unparse e

unparse (Expr_Constant cons) = do
unparse cons

unparse (Expr_In e inSpec) = parens $ do
unparse e
kw IN
oneline (unparse inSpec)

unparse (Expr_Between e1 e2 e3) = parens $ do
unparse e1
kw BETWEEN
unparse e2
kw AND
unparse e3

unparse (Expr_Cast e datatype) = do
kw CAST `catThen` parens (do
unparse e
kw AS
unparse datatype)

unparse (Expr_IsNull e) = parens $ do
unparse e
kw IS
kw NULL

...

As you can see, sometimes there is a need to use a different composition
operator (catThen).

I think that this technique, simple as it is, can be very useful for
more complicated programs, especially if pretty-printing has to be
interleaved with some computational effects. It also helps to achieve
good modularity, by "dispatching on the monad type", which helps me to
handle two different dialects of SQL with quite good code reuse.


But getting to the point... I wonder if such a pattern was used or
proposed before. I tried to find some mention of it, but with no luck
(or luck :). Most examples of Writer monad use are about logging, etc.

If there are no protests, I am going to claim I was the first to use
such a technique. It may help me to rescue my poor master's thesis ;)

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Applicative translucent functors in Haskell

2004-09-08 Thread Tomasz Zielonka
On Wed, Sep 08, 2004 at 04:27:23PM +0100, Simon Peyton-Jones wrote:

> The ML orthodoxy says that it's essential to give sharing constraints by
> name, not by position.  If every module must be parameterised by every
> type it may wish to share, modules might get a tremendous number of type
> parameters, and matching them by position isn't robust. I think that
> would be the primary criticism from a programming point of view.  I have
> no experience of how difficult this would turn out to be in practice.

How about named fields in type constructors? Something like Haskell's
records but at type level. Seems like a fun extension ;)

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Dependent types, was:2-D Plots, graphical representation of massive data

2004-08-28 Thread Tomasz Zielonka
On Fri, Aug 27, 2004 at 10:26:51AM -0400, Michael Manti wrote:
> I recognize that I'm far out of my depth here--both in Haskell and in
> mathematics--but I'll ask anyway. In what ways are dependent types
> (http://haskell.org/hawiki/FunDeps,
> http://www.cse.ogi.edu/~mpj/pubs/fundeps.html) insufficient to address
> these issues? 

I think you are confusing Dependent Types with Functional Dependencies.
They are two completely different things. The former means a type system
in which types can depend on values, the latter (in context of type
systems) is an extension of type classes which allows to eliminate
unnecessary ambiguities.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Sequencing of input and output, troubles in kdevelop

2004-08-27 Thread Tomasz Zielonka
On Fri, Aug 27, 2004 at 06:24:10PM +0200, Ketil Malde wrote:
> 
> Yes, that's true, a nonexisting file name should cause it to terminate
> before output is complete, I guess.  It's slightly irrelevant, though,
> because the problem isn't the laziness in Haskell, but the laziness in
> the operating system in the form of buffering of output.

This kind of buffering is performed in user-space, and not by the
operating system. In this case it is GHC's implementation of Handles.
Most other language implementations also use this technique.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] XML Serialization and type constraints

2004-08-25 Thread Tomasz Zielonka
On Wed, Aug 25, 2004 at 08:38:51PM +0100, Simon D. Foster wrote:
> Ok then, well it looks like this method is going to very cumbersome to
> use; for example a context for a reasonably simple complex data-type
> would be;
> 
> (Hook Element t, Hook Bool t, Hook [ERS] t, Hook (Selection ERS) t, Hook
> ERS t, Hook (Maybe PackedString) t, Hook PackedString t, Hook
> IsQualified t, Hook (Ser t) t, Hook Int t, Hook (Maybe QName) t, Hook
> QName t)

Well, yes, that can be tiresome. You can copy/paste this from compiler
error message, but that won't help you to keep these huge contexts up to
date if you remove some fields of your data types.

Hmmm, it is worse that I thought. The contexts will accumulate, like a
snowball. If you have:

data A = A Int
data B = B A
data C = C B
data D = D C

then in the instance for D you would have to include context for all
Int, A, B, C and D.

Apparently this solution doesn't scale. I can think about some hack, but
I'm not sure you will like it, because it introduces more type classes,
one per datatype.

  data S = S { sA :: Int, sB :: String, sC :: [Int] }

  class (Mixin Int t, Mixin Char t, Mixin String t, Mixin [Int] t, Mixin S t) => 
Mixin_S t
  instance (Mixin Int t, Mixin Char t, Mixin String t, Mixin [Int] t, Mixin S t) => 
Mixin_S t

  instance (Mixin_S t) => Serializer S t where
  encodePrim t s =
  concat
  [ "S { "
  , encode t (sA s)
  , ", "
  , encode t (sB s)
  , ", "
  , encode t (sC s)
  , " }"
  ]

  data R = R { rA :: Int, rS :: S }

  class (Mixin_S t, Mixin Int t, Mixin R t) => Mixin_R t where
  instance (Mixin_S t, Mixin Int t, Mixin R t) => Mixin_R t where

  instance (Mixin_R t) => Serializer R t where
  encodePrim t r =
  concat
  [ "R { "
  , encode t (rA r)
  , ", "
  , encode t (rS r)
  , " }"
  ]

I am moving this big contexts to superclasses of additional classes
Mixin_S and Mixin_R. This way the contexts don't accumulate. These
class/instance pairs could be easily generated with Template Haskell.
But it's a bit ugly.

> Is there any other way of doing this without another type-class?

That would be interesting.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] XML Serialization and type constraints

2004-08-25 Thread Tomasz Zielonka
On Wed, Aug 25, 2004 at 04:14:48PM +0100, Simon D. Foster wrote:
> I think I jumped the gun it a bit; it almost works, but when I try to
> declare a serializer for a type with several parts e.g.
> 
> data Person = Person PackedString PackedString Int
> 
> instance (Hook Person t) => Serializer Person t where ...
> 
> If I try to call encode on any of the attributes I get;
> 
> Could not deduce (Hook PackedString t)
> from the context (Serializer Person t,
>   Hook Person t,
>   Hook Person t)
> 
> Thus, I have to add a (Hook x t) constraint for every type that is part
> of the given data-type. For your example try;
> 
> data D = D Int  
> instance (Mixin D t) => Serializer D t where
>   encodePrim t (D n) = "(D " ++ encode t n ++ ")"
> 
> Is there anyway of getting around this?

Perhaps you could just 'encode Id' that parts?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] XML Serialization and type constraints

2004-08-25 Thread Tomasz Zielonka
On Wed, Aug 25, 2004 at 01:54:08PM +0100, Simon D. Foster wrote:
> On Wed, 2004-08-25 at 08:39, Tomasz Zielonka wrote:
> - snip -
> 
> > I hope that helps,
> > 
> > Best regards,
> > Tom
> 
> That method works perfectly! Thank you so much! I assume there is no way
> of achieving this without overlapping instances?

Not overlapping, only undecidable. Well, I am not sure. I already
thought about it and I think that it would be possible, but the code
could be much less readable. These instances should be quite 'decidable',
unless someone makes instances of Serializer and Mixin mutually
recursive.

Maybe I will try after work, unless someone else has some good idea?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] XML Serialization and type constraints

2004-08-25 Thread Tomasz Zielonka
On Tue, Aug 24, 2004 at 07:35:46PM +0100, Simon D. Foster wrote:
> I'm trying to implement an extensible XML De/Serializer in Haskell for
> use with SOAP and XML Schema (using the Haskell XML Toolbox). The idea
> is you have a type-class, which is instantiated for each type you want
> to encode/de-encode. This class (atm) takes the form;
> 
> class XMLSerializer a where
> encodeElements:: NamespaceTable -> Flags -> a -> [XmlFilter]
> encodeAttributes  :: NamespaceTable -> Flags -> a -> [XmlFilter]
> encodeTree  :: NamespaceTable -> String -> Flags -> a -> XmlFilter
> encodeTrees :: NamespaceTable -> String -> Flags -> a -> [XmlFilter]
> 
> decodeAttribute   :: String -> XmlTree -> Maybe a
> decodeElement :: XmlTree -> Maybe a
> decodeTree:: XmlTree -> Maybe a
> decodeTrees   :: XmlTrees -> Maybe a
> 
> (and a few default instances)
> 
> This type-class can then be used recursively to build XML
> representations of Haskell data.
> 
> I now want to expand this system to make is more extensible. For
> starters, to make it useful with SOAP, I need to add optional explicit
> typing of data. To this end I have another class; XSDType, which stores
> the XSD equivalent name and name-space for a particular Haskell type.
> This is what is used to add explicit type data to the XML documents.
> Adding this data involves adding an extra attribute to each node in the
> tree. More generally however each "Hook", which adds extra data at each
> node has type NamespaceTable -> Flags -> a -> ([XmlFilter],
> [XmlFilter]), where a is the type of the value.
> 
> However, this is where the problem comes. How do I go about expressing
> that a has a constraint XSDType a? I don't want to add this constraint
> to the Serializer class itself since an XML tree may not be typed by
> XSD. Somehow I need a way of adding extra constraints to a dynamically.

Here is one possible solution. Below is a working implementation for a
simpler class scheme. You should be able to apply this to your problem,
at least in case of adding XSD types, if not generally.

  {-# OPTIONS -fglasgow-exts #-}
  {-# OPTIONS -fallow-undecidable-instances #-}

  module B where

  import List
  import Data.Typeable -- Just to implement one of example mixins

  -- Mixin class - could have better name

  class Mixin a t where
  mixin :: t -> a -> (String -> String)

  -- Serializer class

  -- class Serializer has an additional parameter t which will be used
  -- for passing a mixin to it. Also it is a subclass of Mixin a t, but
  -- it doesn't mean adding unneccesary constraints to Serializer -
  -- one of Mixin's implementations will be identity.
  --
  -- It is important that encodePrim's implementations don't call
  -- directly to encodePrim, only to encode, which makes the
  -- mixin work.
  class Mixin a t => Serializer a t where
  encodePrim :: t -> a -> String

  encode :: Serializer a t => t -> a -> String
  encode t x = mixin t x (encodePrim t x)

  -- Serializer instances - I used undecidable instances here.

  instance Mixin Int t => Serializer Int t where
  encodePrim _ = show

  instance Mixin Char t => Serializer Char t where
  encodePrim _ = show

  instance (Serializer a t, Mixin [a] t) => Serializer [a] t where
  encodePrim t l = "[" ++ concat (intersperse ", " (map (encode t) l)) ++ "]"

  -- example Mixins

  data Id = Id

  instance Mixin a Id where
  mixin Id _ = id

  data TypeOf = TypeOf

  instance Typeable a => Mixin a TypeOf where
  mixin TypeOf t s = "(" ++ s ++ " :: " ++ show (typeOf t) ++ ")"

  instance Mixin a (String -> String) where
  mixin f a = f

  -- this one can be used for combining mixins
  instance (Mixin a x, Mixin a y) => Mixin a (x, y) where
  mixin (x, y) a = mixin x a . mixin y a

  -- some unTypeable type

  data T a = T a

  instance (Serializer a t, Mixin (T a) t) => Serializer (T a) t where
  encodePrim t (T a) = "(T " ++ encode t a ++ ")"

Example uses:

  *B> putStrLn $ encode Id 'a'
  'a'
  *B> putStrLn $ encode TypeOf 'a'
  ('a' :: Char)
  *B> putStrLn $ encode Id ([1..4] :: [Int])
  [1, 2, 3, 4]
  *B> putStrLn $ encode TypeOf ([1..4] :: [Int])
  ([(1 :: Int), (2 :: Int), (3 :: Int), (4 :: Int)] :: [Int])
  *B> putStrLn $ encode (TypeOf, TypeOf) ([1..4] :: [Int])
  (([((1 :: Int) :: Int), ((2 :: Int) :: Int), ((3 :: Int) :: Int), ((4 ::
  Int) :: Int)] :: [Int]) :: [Int])
  *B> putStrLn $ encode Id (T "Hello")
  (T ['H', 'e', 'l', 'l', 'o'])
  *B> putStrLn $ encode TypeOf (T "Hello")

  :1:
  No instances for (Typeable (T [Char]), Show (IO ()))
arising from use of `encode' at :1
  In the second argument of `($)', namely `encode TypeOf (T "Hello")'
  In the definition of `it':
  it = putStrLn $ (encode TypeOf (T "Hello"))

  :1:
  No instances for (Typeable (T [Char]), Show (IO ()))
arising from use of `print' at :1
  In a 'do' expression: print it

I hope that helps,

Best reg

Re: [Haskell] Re: HsDNS -- asynchronous DNS resolver

2004-06-18 Thread Tomasz Zielonka
On Fri, Jun 18, 2004 at 11:17:52AM +0200, Peter Simons wrote:
> Tomasz Zielonka writes:
> 
>  >> http://cryp.to/hsdns/
> 
>  > You stole my project's name!
> 
> I have to admit that I am uncertain whether you are kidding
> or whether this is a serious complaint, but in case of the
> latter, I'll change the name to HsADNS or whatever. I can't
> say I am emotionally invested in how this thing is called,
> so if it's important to you ... let me know and I'll change
> it.

I am sorry, I forgot the smiley. A bit late, but here it is: ;)
Please, keep the current name.

Maybe we could have two implementations behind one interface?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] HsDNS -- asynchronous DNS resolver

2004-06-17 Thread Tomasz Zielonka
On Thu, Jun 17, 2004 at 02:20:49PM +0200, Peter Simons wrote:
> On top of the GNU adns library, I have implemented a pretty
> simple-to-use DNS resolver, which hides the concurrency from
> the user through the use of MVars. I thought, maybe someone
> found this useful. You can get the source code at:
> 
>   http://cryp.to/hsdns/

You stole my project's name! Oh, well, I guess I should have 
released it, now I can't complain :(

BTW, my library is pure Haskell. In a month or two I'll try to replace
Parsec (yes, I used Parsec to decode DNS packages :) with my
UArrayParser, implement full domain name resolution algorithm, think of
another name, and release it.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] IO question

2004-06-11 Thread Tomasz Zielonka
On Fri, Jun 11, 2004 at 01:23:11PM +0200, Tom Hofte wrote:
> I want to have a function that unpack an IO.
> I should have the type: IO a -> a.
> Is this possible?

There is unsafePerformIO, but before you use it, think - do you
really, really want to use it and you really, really know what the
consequences can be? Perhaps you could tell us what it is that you think
you need unsafePerformIO for? Maybe it can be done without it?

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Updates using Field Labels

2004-05-17 Thread Tomasz Zielonka
On Mon, May 17, 2004 at 05:22:02PM +0200, Tomasz Zielonka wrote:
> I think you should change ,,Signature'' in lines 50, 56 to
> ,,peSig event''. Right now you are using record construction,
> not update.

,,(peSig event)'' to be precise.

Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Updates using Field Labels

2004-05-17 Thread Tomasz Zielonka
On Mon, May 17, 2004 at 11:11:52AM -0400, Gregory Wright wrote:
> When I run the real program or the attached sample program I get the
> error
> 
> Fail: ios.hs:50: Missing field in record construction Main.sigPriority
> 
> (This is using GHC-6.2.1 on Mac OS X 10.3.3 built from darwinports.)
> 
> I don't understand the reason for this error message. It seems to
> be more constraining than my reading of section 3.15.3 of the
> Report (Updates Using Field Labels).

I think you should change ,,Signature'' in lines 50, 56 to
,,peSig event''. Right now you are using record construction,
not update.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] ANNOUNCE: cpphs-0.2

2004-05-16 Thread Tomasz Zielonka
On Sat, May 15, 2004 at 09:30:47PM +0100, Malcolm Wallace wrote:
> I believe this to be a reasonably complete and correct implementation,
> and have tested it on some non-trivial examples from the standard
> libraries (e.g. Foreign.Storable and HOpenGL).  Nevertheless, there
> will be bugs and I encourage you to find them and report them.

If you want to really stress your program, check Boost.Preprocessor
library.  This is a library of arithmetic operations, data structures,
looping constructs, etc. all implemented entirely in C preprocessor.

  http://www.boost.org/libs/preprocessor/index.html

The distribution of Boost contains regression tests for preprocessor
library. It's placed in libs/preprocessor/test/. Right now cpphs doesn't
pass any test, because it trips on comments after #.

And now two error reports from me.

1.  #define C D D
#define B C C
#define A B B
A

should expand to

D D D D D D D D

not

D D C B

2.  #define F(x) #x
F(abcd efg)

should expand to

"abcd efg"

not

#abcd efg

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


  1   2   >