After all, Java basically does exactly what you're asking for with
Java's head/tail would be doing runtime checks if they are throwing exceptions,
static guarantees mean the program would not be allowed to compile if it broke
the static guarantees.
end-programmers have to worry much less about
After all, Java basically does exactly what you're asking for with
Java's head/tail would be doing runtime checks if they are throwing exceptions,
static guarantees mean the program would not be allowed to compile if it broke
the static guarantees.
Not so. In Java, the programmer is forced
Not so. In Java, the programmer is forced to handle most exceptions
I forgot you had to do that... Exceptions are explicit in the type
signatures. I think Oleg posted a message a while back about how to
make exceptions explicit in haskell type signatures... But I would
rather use static
Static guarantees are great, but if you have to explicitly change your
style of coding to cope with those extra constraints, it can become (very)
cumbersome.
I had to change coding style moving from imperative to declarative languages,
but I think it was worth it... Likewise I think having the
correctly sorted lists under _all_ circunstances. This type signature
is much simpler than the actual sort - hence is useful.
sort :: (HList l,HOrderedList l') = l - l'
Nice and readable, and much simpler than the actual algorithm (be
it bubble sort, or a quick sort)
The type
You should include the definitions of the classes before saying
HOrderedList l' just has to prove by induction that for any element
in the list, the next element is greater, so the class is simply:
class HOrderedList l
instance HNil
instance HCons a HNil
instance (HOrderedList (HCons b l),HLe a
On Fri, 2004-08-06 at 14:05, MR K P SCHUPKE wrote:
You should include the definitions of the classes before saying
HOrderedList l' just has to prove by induction that for any element
in the list, the next element is greater, so the class is simply:
class HOrderedList l
instance HNil
Can you name these fields? If so, haskell has (sorta clumsy) named
records,
and you can select and update fields by name, and you can replace
'setSFField 3 sf x' with 'sf {somefield=x}'
I did think of this, but unfortunatly my algorithm cant use names (without
hard coding all possible
On Fri, 2004-08-06 at 15:44, Malcolm Wallace wrote:
Hmm...doesn't
--8--
module Closed(foo) where
class C a where foo = ...
instance C ...
--8--
module Main where
import Closed
...foo...
--8--
do what you want? You can only use
Malcolm Wallace [EMAIL PROTECTED] writes:
Ah, but now you cannot use (Closed t) = as a predicate in type
signatures, and since you cannot write a partial signature, you must
omit the signature altogether...
Hmm..yes, that would be a disadvantage. :-)
-ketil
--
If I haven't seen further, it
On 06/08/2004, at 6:56 PM, MR K P SCHUPKE wrote:
After all, Java basically does exactly what you're asking for with
Java's head/tail would be doing runtime checks if they are throwing
exceptions,
static guarantees mean the program would not be allowed to compile if
it broke
the static
Malcolm Wallace wrote:
and since you cannot write a partial signature,
Can't we really?
It seems `partial signature' means one of two things:
- we wish to add an extra constraint to the type of the function
but we don't wish to explicitly write the type of the
This class definition is giving me a lot of problems with the successor
function:
class (Ord st) = MinimaxState st where
successors:: st - [(action,st)]
terminal:: st - Bool
A trivial example would be:
instance MinimaxState Int where
terminal i = i == 0
successors i = [(1,i+1), (-1,i-1)]
13 matches
Mail list logo