I want a show - instance for that type: data Bind a = Zero | Succ a resp. for the types (Bind ( ... (Bind a)...)) showing the following: show (Succ ( ... (Succ Zero)..)) = n (where n is the number of Succ's) and show (Succ ( ... (Succ x)..)) = show x (when x != Zero) ------------------------------------------------ And - a very similar problem - i'd like to have a function 'count' which get something of type 'Bind' and returns a value of type (Either Int a): count ((Succ ( ... (Succ Zero)..)) = Left n (n = #succ's) and count (Succ ( ... (Succ x)..)) = Right x (x != Zero) ------------------------------------------------- Does anyone know, how to define those functions in haskell/hugs ?? (Are they defineable at all?) Thanks, -Tobi -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net GMX Tipp: Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1! http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a
participants (1)
-
Tobias Haeberlein