ML like pattern matching

2003-08-22 Thread Cagdas Ozgenc
Greetings, How do I emulate the "when" clause in ML for pattern matching? In other words when a pattern is matched (from a list of patterns of a function)and to enforce additional predicates I use guards, but if the guard condition is not satisfied I want Haskell toget back totrying

Re: ML like pattern matching

2003-08-22 Thread Cagdas Ozgenc
Thanks. I was reading some codes in ML, and it was commented this was the case. I didn't know Haskell had the equivalent behavior. I always thought once the pattern was matched there is no going back. I may be confused about what you're asking for, but Haskell does this by default: foo (Left

Re: is identity the only polymorphic function without typeclasses?

2003-03-03 Thread Cagdas Ozgenc
Cagdas Ozgenc [EMAIL PROTECTED] wrote: Greetings, Is identity function the only meaningful function one can write without constraining the type variable using a typeclass? If not, could you please give a counter-example? Certainly you can write lots of ``meaningful function''s

Re: modeling out of memory

2003-03-03 Thread Cagdas Ozgenc
Greetings, 1) How does one model out of memory condition in Haskell, perhaps using a Maybe type? Unfortuntely not since it would not be referentially transparent. It's part of a more general issue of exceptions in pure code. You can't have calculateSomething :: X - Maybe Y Such

Re: is identity the only polymorphic function without typeclasses?

2003-03-03 Thread Cagdas Ozgenc
I did not mean to include functions that take type constructors as parameters (so lists are out of my discussion scope). I am only considering functions that uses type variables that are not restricted by typeclasses. There is const: const :: a - b - a const x _ = x And of

Re: is identity the only polymorphic function without typeclasses?

2003-03-03 Thread Cagdas Ozgenc
My three eurocents. I believe that the Author of the original query won't care more about undefined stuff than most of us. He wants truly polymorphic functions, of the type, say, a-b-a etc., without constraints. The answer exists, although it is not always trivial to find interesting

modeling out of memory

2003-03-02 Thread Cagdas Ozgenc
Greetings, 1) How does one model "out of memory" condition in Haskell, perhaps using a Maybe type? 2) Could you give an intutive description of data construction, and how it relates to lamda calculus? Thanks

is identity the only polymorphic function without typeclasses?

2003-03-02 Thread Cagdas Ozgenc
Greetings, Is identity function the only meaningful function one can write without constraining the type variable using a typeclass? If not, could you please give a counter-example? Thanks

Re: arrays and lamda terms

2003-02-05 Thread Cagdas Ozgenc
Thanks for the example. It is quite sophisticated. I can see how you select an element randomly using the function parameters (it's cheating actually because lamda calculus will still reduce this it in steps, so it works for Haskell implementation because it does things smarter) One thing I

arrays and lamda terms

2003-02-04 Thread Cagdas Ozgenc
Greetings. My question is not directly related to Haskell. Is it possible to encode an array using lamda terms only, and recover the term specified by an index term in O(1) time (in other words in one step reduction, without cheating using several steps behind the scenes)? Or is it

Re: arrays and lamda terms

2003-02-04 Thread Cagdas Ozgenc
The formula involves the addition of two numbers -- which is, generally, a O(log(n)) operation. Granted, if we operate in the restricted domain of mod 2^32 integers, addition can be considered O(1). If we stay in this domain however, the size of all our arrays is limited to M (which is 2^32,

typeclass versioning

2002-06-12 Thread Cagdas Ozgenc
Greetings. What happens ifa type is made an instance of a typeclass in two different modules with different implementations? In static linking scenarios it will be caught by the compiler. I don't know whether we can do dynamic loading in Haskell, but it seems there will be inconsistencies

Re: type equivalency

2002-06-06 Thread Cagdas Ozgenc
Thanks for all the responses. They were indeed very helpful. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Type equivalency 2

2002-06-06 Thread Cagdas Ozgenc
The type constructor F and the type constructor (-) are quite different. They have the same kind, but just as the type only tell you part of what a value is, thekind only tells you part of what a type is. Very informally a value of type F a b means I have an a and a b, whereas as type a -

type equivalency

2002-06-05 Thread Cagdas Ozgenc
Greetings. I know 2 special type constructors(there might be other that I do not know yet) - and ( , ) where structural type equivalency is enforced and we can also create new types with an algebric type constructor notation where name equivalency is enforced. What is the rationale? I mean

Re: type equivalency

2002-06-05 Thread Cagdas Ozgenc
as different because of name equivalency testing. Basically there are 2 type constructors - ( , ) with structural equivalency, which is odd. Someone just dumped some idiosyncracies of lamda calculus into the language. Thanks again. Cagdas Ozgenc writes: | Greetings. | | I know 2 special type

typeclasses

2002-03-22 Thread Cagdas Ozgenc
Greetings. How can I make all types that belong to class A and instance of class B, if the implementations of functions in class B can be realizedby only using the functions in class A? Thanks for taking time.

partial application

2002-03-18 Thread Cagdas Ozgenc
Greetings. Is there a reason why partial application cannot be applied in arbitrary order? Wasit a technical difficulty in the design of Haskell? Or is it just following beta reduction rigorously? Thanks

Re: Hiring Haskell programmers

2002-03-11 Thread Cagdas Ozgenc
At 2002-03-11 17:05, Mark Carroll wrote: When I first learned Standard ML, after years of imperative programming, my brain almost hurt for the first few weeks. For me the difference is that in imperative you tell the computer what to do, whereas in FP you tell the computer what things

if - is a type constructor

2002-02-21 Thread Cagdas Ozgenc
Greetings folks. If (-) is a type constructor, what does its definition look like, what data constructors does it have? How does it differ from other type constructors, or maybe it doesn't? Could someone give an explanation... Thanks for taking time.

Re: add something to a list

2002-02-17 Thread Cagdas Ozgenc
You seem to expect currentPath to be updated by putpiece? This won't happen in Haskell. Once you've declared currentPath=[] it will always be []. Values never change. If you want the functional equivalent of accumulator variables they have to be an argument of a recursive

Q about haskell-report

2002-01-28 Thread Cagdas Ozgenc
Greetings. In section 4.1 of Haskell Report for 98: It is indicated that (-) has kind * - *- * and t1 - t2 is equivalent to type (-) t1 t2 Does this make (-) a type constructor? Is this an attempt to unify functions and data types? Thanks ___

functions not in type classes

2002-01-18 Thread Cagdas Ozgenc
Greetings. Why does Haskell let you write functions that are not a part of type class? For example instead of elem :: Eq a = a - [a] - Bool map :: (a - b) - [a] - [b] class Container a where elem :: Eq b = b - a b - Bool map :: (b - c) - a b - a c would define methods that can work on

Re: functions not in type classes

2002-01-18 Thread Cagdas Ozgenc
the goal of type class is to allow overloading of function, so for example id x = x is not subject to overloading = no use to put it in a type class. Because it doesn't do anything? elem :: Eq a = a - [a] - Bool map :: (a - b) - [a] - [b] class Container a where elem :: Eq

Re: functions not in type classes

2002-01-18 Thread Cagdas Ozgenc
Thanks. I am quite convinced actually (no sarchasm involved). On Fri, 18 Jan 2002, Cagdas Ozgenc wrote: the goal of type class is to allow overloading of function, so for example id x = x is not subject to overloading = no use to put it in a type class. Because it doesn't do

Hashtable ADT

2001-10-06 Thread Cagdas Ozgenc
Hi, As I understand from the concepts of Functional Programming, it is not possible to implement a Hashtable ADT in Haskell language, where one can insert, and access values in O(1) complexity. It has to be implemented with an external language. Is my argument correct? Thanks for taking