Re: UTF-8 decoding

2006-02-11 Thread Marcin 'Qrczak' Kowalczyk
John Meacham [EMAIL PROTECTED] writes:

 Another possibility is quasi-utf8 encoding. where it passes through any
 invalid utf8 sequences as latin1 characters. in practice, this works
 very well as interpreting both latin1 and utf8 transparently but is
 more than somewhat hacky.

It would not be reliable. I'm strongly against that: it gives an
illusion that Latin1 works, but it breaks in very rare cases.

-- 
   __( Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-11 Thread Ben Rudiak-Gould

David Menendez wrote:

Ben Rudiak-Gould writes:
|  forall a. (forall b. Foo a b = a - b) - Int
| 
| is a legal type, for example.


Is it? GHCi gives me an error if I try typing a function like that.


This works:

f :: forall a. (forall b. Foo a b = a - b) - Int
f _ = 3

I interpret this type as meaning that you can call the argument provided you 
can come up with an appropriate b. If you can't come up with one then you 
can't call the argument, but you can still ignore it and type check.


If you had, for example,

instance Foo a Char
instance Foo a Int

then you would be able to use the argument polymorphically at b=Char and b=Int.

f = undefined also works if you have instance Foo a b (which is only 
allowed with -fallow-undecidable-instances). I think it's because of 
predicativity that it fails without it.


Presumably forall a. (Ord a = a- a) - Int could be allowed as well, but 
if you're called with a = IO () then you can't call your argument, therefore 
you can never call your argument, therefore it's not a useful type in practice.


-- Ben

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


Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-11 Thread Brian Hulley

Ben Rudiak-Gould wrote:

David Menendez wrote:

Ben Rudiak-Gould writes:

 forall a. (forall b. Foo a b = a - b) - Int

is a legal type, for example.


Is it? GHCi gives me an error if I try typing a function like that.


This works:

f :: forall a. (forall b. Foo a b = a - b) - Int
f _ = 3

I interpret this type as meaning that you can call the argument
provided you can come up with an appropriate b. If you can't come up
with one then you can't call the argument, but you can still ignore
it and type check.
If you had, for example,

instance Foo a Char
instance Foo a Int

then you would be able to use the argument polymorphically at b=Char
and b=Int.
f = undefined also works if you have instance Foo a b (which is only
allowed with -fallow-undecidable-instances). I think it's because of
predicativity that it fails without it.

Presumably forall a. (Ord a = a- a) - Int could be allowed as
well, but if you're called with a = IO () then you can't call your 
argument,

therefore you can never call your argument, therefore it's not a
useful type in practice.



Thanks (also to Stefan) for clarifying that f's type is indeed legal. 
However I still think that there is a bit of confusion about what the syntax 
is supposed to mean, because:


  f :: forall a. (forall b. Foo a b = a - b) - Int

is effectively being used as a shorthand for (the illegal syntax):

  f :: forall a. (forall c. Foo a c) = (forall b. Foo a b = 
a-b)-Int


whereas

  g :: forall a. (Ord a = a-a)-Int

is *not* being seen as a quick way of writing:

 g :: forall a. Ord a = (Ord a = a-a)-Int

(which would further reduce to g:: forall a. Ord a= (a-a)-Int because 
there's no need for the constraint on 'a' to be written twice)


In both cases, for the argument to be useable, 'a' needs to be constrained 
in the general case. The fact that all instances of Foo may happen to be 
polymorphic in the 'a' argument is surely just a special case, which would 
still be covered by the (forall c. Foo a c) constraint.


I think a question for the syntax is: are we to understand quantifiers and 
class constraints in terms of logic, or are they supposed to only be 
understood in terms of some specific implementation eg passing a dictionary?


If we are to understand them in terms of logic alone, I would suggest a 
general rule that all types could be (internally) converted into a normal 
form by propagating all constraints back to the relevant quantifier and 
eliminating any redundant constraints that are left, so that we would get 
the advantage of the existing shorthand while still allowing a simple way 
of understanding what's going on even in the presence of multi-param type 
classes.


Regards, Brian.


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


Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-11 Thread Brian Hulley

Brian Hulley wrote:

Thanks (also to Stefan) for clarifying that f's type is indeed legal.
However I still think that there is a bit of confusion about what the
syntax is supposed to mean, because:

  f :: forall a. (forall b. Foo a b = a - b) - Int

is effectively being used as a shorthand for (the illegal syntax):

  f :: forall a. (forall c. Foo a c) = (forall b. Foo a b =
a-b)-Int

whereas

  g :: forall a. (Ord a = a-a)-Int

is *not* being seen as a quick way of writing:

 g :: forall a. Ord a = (Ord a = a-a)-Int

(which would further reduce to g:: forall a. Ord a= (a-a)-Int
because there's no need for the constraint on 'a' to be written twice)

In both cases, for the argument to be useable, 'a' needs to be
constrained in the general case. The fact that all instances of Foo
may happen to be polymorphic in the 'a' argument is surely just a
special case, which would still be covered by the (forall c. Foo a c)
constraint.
I think a question for the syntax is: are we to understand
quantifiers and class constraints in terms of logic, or are they
supposed to only be understood in terms of some specific
implementation eg passing a dictionary?
If we are to understand them in terms of logic alone, I would suggest
a general rule that all types could be (internally) converted into a
normal form by propagating all constraints back to the relevant
quantifier and eliminating any redundant constraints that are left,
so that we would get the advantage of the existing shorthand while
still allowing a simple way of understanding what's going on even in
the presence of multi-param type classes.



Actually please ignore the above! :-)
I see now that all these things have useful meanings as they stand at the 
moment, and that there would never be any need for a constraint such as 
(forall c. Foo a c), because that actual 'c's used in the function body 
could all be explicitly enumerated by a series of constraints in the case 
where the relevant instances were not polymorphic in 'a' eg


f :: forall a. (Foo a Char, Foo a Int) = (forall b. Foo a b = 
a-b) - Int
h :: forall a b c. (Foo a b, Foo a c) =(forall d. Foo a d = 
a-d) - a - (b,c)

h g x = (g x, g x)

Thanks to all who helped further my understanding of the interaction between 
constraints and arbitrary rank polymorphism! :-)


Brian. 


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