[Haskell-cafe] order of arguments matters

2011-03-18 Thread Peter Padawitz
Why does only tr2 work, although the only difference between tr1 and tr2 is the order of arguments? import Data.Tree (Tree(..)) data Type a where Tree:: Type a -> Type (Tree a) Int :: Type Int String :: Type String type Traversal1 = forall a.a -> T

[Haskell-cafe] Set monad

2011-01-08 Thread Peter Padawitz
Hi, is there any way to instantiate m in Monad m with a set datatype in order to implement the usual powerset monad? My straightforward attempt failed because the bind operator of this instance requires the Eq constraint on the argument types of m. Peter ___

[Haskell-cafe] lazy evaluation is not complete

2009-02-09 Thread Peter Padawitz
A simplied version of Example 5-16 in Manna's classical book "Mathematical Theory of Computation": foo x = if x == 0 then 0 else foo (x-1)*foo (x+1) If run with ghci, foo 5 does not terminate, i.e., Haskell does not look for all outermost redices in parallel. Why? For efficiency reasons? It'

[Haskell-cafe] monad constraint + record update

2008-12-22 Thread Peter Padawitz
I'd like to define a monad Set for types in the class Eq. But how can the arguments of Set be constrained when Set is defined as an instance of Monad? instance Eq a => Monad Set where ... obviously cannot work. Is there a standard update function for fields in data types, something that OO pro

[Haskell-cafe] compilation question

2008-11-11 Thread Peter Padawitz
At first a type of arithmetic expressions and its generic evaluator: data Expr = Con Int | Var String | Sum [Expr] | Prod [Expr] | Expr :- Expr | Int :* Expr | Expr :^ Int data ExprAlg a = ExprAlg {con :: Int -> a, var :: String -> a, sum_ :: [a] -> a, prod :: [a] -> a, s

Re: [Haskell-cafe] lazy evaluation

2008-02-06 Thread Peter Padawitz
ative version of eqrev' -- if x and y were not mixed up. Peter Peter Padawitz wrote: Can anybody give me a simple explanation why the second definition of a palindrome checker does not terminate, although the first one does? pal :: Eq a => [a] -> Bool pal s = b where (b,r) = eqr

[Haskell-cafe] lazy evaluation

2008-02-06 Thread Peter Padawitz
Can anybody give me a simple explanation why the second definition of a palindrome checker does not terminate, although the first one does? pal :: Eq a => [a] -> Bool pal s = b where (b,r) = eqrev s r [] eqrev :: Eq a => [a] -> [a] -> [a] -> (Bool,[a]) eqrev (x:s1) ~(y:s2) acc = (x==y&&b,r) whe

[Haskell-cafe] type classes

2007-12-14 Thread Peter Padawitz
I'd like to define several instances of the same type class with the same type variable instance. Only method instances differ. How can I do this without writing copies of the type class? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://w

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: What is so bad about making compFoo part of the class? It reduces the code (constraints can be avoided) and reflects the close connection between a signature Sig (implemented by the class) and the

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: What is so bad about making compFoo part of the class? It reduces the code (constraints can be avoided) and reflects the close connection between a signature Sig (implemented by the class) and the evaluation (compFoo) of Sig-terms in Sig-algebras

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Peter Padawitz
Jules Bean wrote: Try again without missing out the list... Peter Padawitz wrote: > Jules Bean wrote: >> Incidentally, I question why the "compFoo" are methods. Why not just make them polymorphic functions? They don't look like you expect instances to change the

[Haskell-cafe] Re: type class question

2007-12-10 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: So the fundep would solve the problem. But, actually, it doesn't :-( But actually, it does! Indeed... Sorry, I think I left intE out of the cycle. This might be the reason why it did not work before. Ben Franksen's answer from

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the ins

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the instantiation conflicts pointed out by others woul

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Peter Padawitz
_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Prof. Dr. Peter Padawitz Informatik 1 University of Dortmund D-44221 Dortmund Germany phone +49-231-755-5108 fax +49-231-755-6555 secr

Re: [Haskell-cafe] type class question

2007-12-06 Thread Peter Padawitz
what are the alternatives? Roughly said, I need a construct that allows me gather several type variables such that an instance is always an instance of all of them. On Dec 3, 2007 7:43 AM, Peter Padawitz <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: What is wrong here

[Haskell-cafe] type class question

2007-12-03 Thread Peter Padawitz
What is wrong here? ghci tries (and fails) to deduce certain types for the comp functions that I did not expect. |type Block = [Command] data Command = Skip | Assign String IntE | Cond BoolE Block Block | Loop BoolE Block data IntE= IntE Int | Var String | Sub IntE IntE | Sum

[Haskell-cafe] Graphics.SOE

2007-09-21 Thread Peter Padawitz
Can scrollbars be attached to windows created with openWindow? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] lazy patterns versus where-clauses

2007-06-21 Thread Peter Padawitz
Is f(~p(x))=e(x) semantically equivalent to: f(z)=e(x) where p(x)=z? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Haskell -> Tk

2007-01-22 Thread Peter Padawitz
Does anybody know O'Haskell or Timber and its interface Tk.hs to Tcl/Tk (see here )? I have the following problem: Tk.hs contains a record (structure) /Canvas/ with selectors line

[Haskell-cafe] HGL documentation

2005-05-02 Thread Peter Padawitz
Is there a HGL documentation in one volume (e.g. pdf file)? Printing all pieces of http://www.haskell.org/ghc/docs/latest/html/libraries/HGL is a little tedious... Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mail

Re: [Haskell-cafe] RFE: Extensible algebraic user-defined data types?

2005-04-29 Thread Peter Padawitz
So many words about a simple thing? I wrote to Dimitry that subtyping in O'Haskell and Timber provides exactly what he wants: data Either a b = Left a | Right b data NEither > Either = None Why has this elegant concept not yet been implemented in standard Haskell? Peter _

constructors in O'Haskell

2003-07-11 Thread Peter Padawitz
How may I hide constructors in O'Haskell 'cause export lists don't work in this language? Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Monad constructors

2003-07-11 Thread Peter Padawitz
Why must every Monad instance be a datatype or newtype, even if there will be just a single constructor? Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Expander2

2002-10-08 Thread Prof. Dr. Peter Padawitz
Expander2: A Formal Methods Presenter and Animator == Expander2 has been designed as a multi-purpose workbench for interactive logical inference, constraint solving, data flow analysis and other procedures building up proofs or computation sequences