Re: [Haskell-cafe] question regarding Data.Array.Accelerate

2012-02-12 Thread Philipp
Nevermind, I just realised I got something mixed up.  Sorry to bother you.

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/question-regarding-Data-Array-Accelerate-tp5476144p5476586.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] question regarding Data.Array.Accelerate

2012-02-11 Thread Philipp
Hi,

I have read the papers about the accelerate package that provides a
high-level interface to nvidia's cuda library and am very intrigued. 
However, I have some start-up problems.  Is this the right place for such
questions?

In particular, I'm having trouble with lifting and unlifting.  From what I
understood, I should be able to use unlift to get an Int from an Exp (Plain
Int), but when I try, for example,

(unlift . lift) (1::Int) :: Int

ghci complains with 

No instance for (Unlift Int).

I have the latest versions of accelerate (accelerate-0.9.0.1) and ghc
(version 7.4.1).

I think I'm missing something obvious, so if any of you could point it out
to me I would be glad.

Thanks,
Philipp

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/question-regarding-Data-Array-Accelerate-tp5476144p5476144.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poll: Do you want a mascot?

2011-11-24 Thread philipp siegmantel
@Wolfgang Jeltsch: I'm sorry, that was indeed my intension.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poll: Do you want a mascot?

2011-11-24 Thread philipp siegmantel
And also: Yes!
(sorry for double post)

On 24 November 2011 20:51, philipp siegmantel
philipp.siegman...@googlemail.com wrote:
 @Wolfgang Jeltsch: I'm sorry, that was indeed my intension.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Philipp Schneider
On 06/30/2011 02:36 PM, Holger Siegel wrote:
 Am 29.06.2011 um 23:50 schrieb Philipp Schneider:

 Hi cafe,

 in my program i use a monad of the following type

 newtype M a = M (State - (a, State))

 i use the monad in two different ways. The type variable a can be a
 pair as in

 interp :: Term - Environment - M (Value,Environment)

 and it can be just a value as in

 type Environment = [(Name, Either Value (M Value))]
 Simple rule: Never return an environment!

 An environment contains local variable bindings, so no subcomputation will 
 ever need to return its environment. I don't know anything about the language 
 your program interprets, but I'm sure that you can rewrite function interp as

   interp :: Term - Environment - M Value

 The structure of the interpreter will become clearer and your problem will 
 vanish.

Hello Holger,

I'm giving two lambda interpreters. The first one is a call by value
interpreter, the second one a call by name interpreter which are
described in Philip Wadler's paper The essence of functional
programming page 4 and 12. Now my task is to write a lazy lambda
interpreter. The exercise is more playful than serious since Wadler's
call by value interpreter is, since written in lazy Haskell, already a
lazy lambda interpreter. (To get true call by value one would need to
force evaluations of the arguments with the seq function.)
For both of Wadler's interpreters the type of the interpertation
function is:
interp :: Term - Environment - M Value

Now to simulate lazy interpretation i need to do the following: Decide
is the value I need already evaluated or is it still a computation. In
the later case I need to evaluate it and save its value in the
environment. This is the reason I changed the type of the interpretation
function to:
interp :: Term - Environment - M (Value,Environment)

I appened my full interpreter. If you can find a more elegant way to
save the newly interpreted values, you are more than welcome to show my
how to do it.

Cheers,
Philipp


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Philipp Schneider
On 06/30/2011 08:25 PM, Philipp Schneider wrote:
 On 06/30/2011 02:36 PM, Holger Siegel wrote:
 Am 29.06.2011 um 23:50 schrieb Philipp Schneider:

 Hi cafe,

 in my program i use a monad of the following type

 newtype M a = M (State - (a, State))

 i use the monad in two different ways. The type variable a can be a
 pair as in

 interp :: Term - Environment - M (Value,Environment)

 and it can be just a value as in

 type Environment = [(Name, Either Value (M Value))]
 Simple rule: Never return an environment!

 An environment contains local variable bindings, so no subcomputation will 
 ever need to return its environment. I don't know anything about the 
 language your program interprets, but I'm sure that you can rewrite function 
 interp as

   interp :: Term - Environment - M Value

 The structure of the interpreter will become clearer and your problem will 
 vanish.

 Hello Holger,

 I'm giving two lambda interpreters. The first one is a call by value
 interpreter, the second one a call by name interpreter which are
 described in Philip Wadler's paper The essence of functional
 programming page 4 and 12. Now my task is to write a lazy lambda
 interpreter. The exercise is more playful than serious since Wadler's
 call by value interpreter is, since written in lazy Haskell, already a
 lazy lambda interpreter. (To get true call by value one would need to
 force evaluations of the arguments with the seq function.)
 For both of Wadler's interpreters the type of the interpertation
 function is:
 interp :: Term - Environment - M Value

 Now to simulate lazy interpretation i need to do the following: Decide
 is the value I need already evaluated or is it still a computation. In
 the later case I need to evaluate it and save its value in the
 environment. This is the reason I changed the type of the interpretation
 function to:
 interp :: Term - Environment - M (Value,Environment)

 I appened my full interpreter. If you can find a more elegant way to
 save the newly interpreted values, you are more than welcome to show my
 how to do it.

 Cheers,
 Philipp
I forgot to add the interpreter.
{-# LANGUAGE OverlappingInstances #-}

import Prelude hiding (lookup, fail)

import Control.Monad
   
-- Basiswerte

data Value= WrongAd
  | WrongAp
  | WrongL
  | Num Int
  | Fun (Either Value (M Value) - M Value)

instance Show Value where
   show WrongAd= wrong add  
   show WrongAp= wrong app 
   show WrongL= wrong lookup   
   show (Num i)  = show i
   show (Fun f)  = function

-- Terme 

data Term = Var Name
  | Con Int
  | Add Term Term
  | Lam Name Term
  | App Term Term deriving Show

-- Interpretation der Terme (Lazy evaluation)

interp :: Term - Environment - M (Value,Environment)
interp (Var x) e   = lookup x e
interp (Con i) e   = return (Num i,e)
interp (Add u v) e =  do
  (a,e) - interp u e
  (b,e) - interp v e
  s - add a b
  return (s,e)
interp (Lam x v) e  = return (Fun (\m - (interp v ((x, m):e)) = return . fst) , e)
interp (App t u) e  = do
  (f,e) - interp t e
  a - (apply f (Right ((interp u e) = return . fst)))
  return (a,e)


add :: Value - Value - M Value
add (Num i) (Num j) = tick = (\() - return (Num (i+j)))
add a b = return WrongAd

apply :: Value - Either Value (M Value) - M Value
apply (Fun k) a= tick = (\() - k a)
apply notFun a = return WrongAp

-- Umgebung

type Environment = [(Name, Either Value (M Value))]
type Name = String

lookup :: Name - Environment - M (Value,Environment)
lookup x eComplete = lookup_h x eComplete
  where
lookup_h x []= return (WrongL,[])
lookup_h x e@((y,b):etl) = 
  if x==y then case b of 
-- schon ausgewertet
Left a - return (a,e) 
-- noch nicht ausgewertet (speichere den ausgewerteten Wert)
Right a - (a = (\x- return (x, (y,Left x):eComplete)))
  else lookup_h x etl

-- Lazy-Interpreter zaehlt die Reduktionen (Wadler: Beispiel 9)

type State = Int

newtype M a = M (State - (a, State))

tick = M (\s - ((), s+1))


instance (Show a,Show b) = Show (M (a,b)) where
   show (M f) = let ((v,_), s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s

instance Show a = Show (M a) where
   show (M f) = let (v, s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s


instance Monad M where
   return a = M (\s - (a, s))
   (M m) = k = M (\s0 - let (a, s1) = m s0
   (M m')  = k a
   in m' s1
  ) 
   fail s = error s -- wird nicht aufgerufen
   
-- Beispiele:

-- test :: Term - String
test t = (interp t [])

term0 = (Con 10)
term0' = (Var x)
term1 = (Add (Con 10) (Con 11))
term2 = (Lam x (Add (Var x) (Con 10)))
term3 = (App term2 (Con 11))
term4 = (Lam x (Add (Var x) (Var x)))
term5 = (App term4 term1)
term6 = (Lam x (Lam y (Add (Var x) (Var y
term7 = (App term6 (Con 10))
term8

Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Philipp Schneider
On 06/30/2011 09:49 PM, Holger Siegel wrote:
 Am 30.06.2011 um 20:23 schrieb Philipp Schneider:

 On 06/30/2011 02:36 PM, Holger Siegel wrote:
 Am 29.06.2011 um 23:50 schrieb Philipp Schneider:

 Hi cafe,

 in my program i use a monad of the following type

 newtype M a = M (State - (a, State))

 i use the monad in two different ways. The type variable a can be a
 pair as in

 interp :: Term - Environment - M (Value,Environment)

 and it can be just a value as in

 type Environment = [(Name, Either Value (M Value))]
 Simple rule: Never return an environment!

 An environment contains local variable bindings, so no subcomputation will 
 ever need to return its environment. I don't know anything about the 
 language your program interprets, but I'm sure that you can rewrite 
 function interp as

  interp :: Term - Environment - M Value

 The structure of the interpreter will become clearer and your problem will 
 vanish.

 Hello Holger,

 I'm giving two lambda interpreters. The first one is a call by value
 interpreter, the second one a call by name interpreter which are
 described in Philip Wadler's paper The essence of functional
 programming page 4 and 12. Now my task is to write a lazy lambda
 interpreter. The exercise is more playful than serious since Wadler's
 call by value interpreter is, since written in lazy Haskell, already a
 lazy lambda interpreter. (To get true call by value one would need to
 force evaluations of the arguments with the seq function.)
 Hello Philipp,

 that's a nice exercise.

 For both of Wadler's interpreters the type of the interpertation
 function is:
 interp :: Term - Environment - M Value

 Now to simulate lazy interpretation i need to do the following: Decide
 is the value I need already evaluated or is it still a computation. In
 the later case I need to evaluate it and save its value in the
 environment. This is the reason I changed the type of the interpretation
 function to:
 interp :: Term - Environment - M (Value,Environment)
 But that won't work: After you have evaluated an entry of the environment, 
 you store the resulting value but you throw away its updated environment. 
 That means, you lose the results of all subcomputations instead of 
 propagating them to all other copies of the environment. Consider the 
 following expression:

 let x = big_computation in let y = x in y + x

 First, big_computation is bound to the name x, resulting in an environment 
 [(x, big_computation)]. Then a closure consisting of this environment 
 together with the right hand side 'x' is bound to the name y. Now y+x is 
 evaluated: The closure is entered, and from its environment the content of x 
 - a call to big_computation - is looked up. Now big_computation is evaluated 
 and the result is bound to x in this environment. After that, this result is 
 also returned as the value of y. But when returning from the evaluation of y, 
 the environment with the updated value of x is lost and you have to 
 re-evaluate it in order to calculate x+y!
Hello Holger,

Can you give me an example of a lambda term in which this would be an issue?
Evaluating the following works just fine in my implementation.
interp (App (Lam x (Add (Var x) (Var x))) big_computation) []
When the first variable x is evaluated my interp function returns the
value and the updated environment. Then to evaluate the second variable
the value is just looked up from this environment.
Of course in the following big_computation would be evaluated twice
(App (Lam x (App (Lam y (Add (Var x) (Var y))) big_computation))
big_computation)
But i simply don't have a concept like let x=y.
 And that is why I say never return an environment. It is either wrong or 
 unnecessary or the resulting semantics of the interpreter is hard to 
 comprehend.

 In order to implement lazy evaluation correctly, you have to maintain some 
 global state in which the thunks are updated. For example, your environment 
 could bind IORefs that contain unevaluated thunks to variable names and 
 update them when the thunk is evaluated. But then your interpreter has to run 
 in the IO monad.
I agree that this would  be the proper way to do it, but I was trying
to minimize the use of monads since they have just been introduced in
the course.
 By the way, do you already know Peter Sestoft's paper Deriving a lazy 
 abstract machine?
I haven't read is so far, but thanks for pointing it out.
 Cheers, Holger

Cheers,
Philipp

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Philipp Schneider
On 06/30/2011 11:46 PM, Holger Siegel wrote:
 Am 30.06.2011 um 22:57 schrieb Philipp Schneider:

 On 06/30/2011 09:49 PM, Holger Siegel wrote:
 (...) But that won't work: After you have evaluated an entry of the 
 environment, you store the resulting value but you throw away its updated 
 environment. That means, you lose the results of all subcomputations 
 instead of propagating them to all other copies of the environment. 
 Consider the following expression:

 let x = big_computation in let y = x in y + x

 First, big_computation is bound to the name x, resulting in an environment 
 [(x, big_computation)]. Then a closure consisting of this environment 
 together with the right hand side 'x' is bound to the name y. Now y+x is 
 evaluated: The closure is entered, and from its environment the content of 
 x - a call to big_computation - is looked up. Now big_computation is 
 evaluated and the result is bound to x in this environment. After that, 
 this result is also returned as the value of y. But when returning from the 
 evaluation of y, the environment with the updated value of x is lost and 
 you have to re-evaluate it in order to calculate x+y!
 Hello Holger,

 Can you give me an example of a lambda term in which this would be an issue?
 Evaluating the following works just fine in my implementation.
 interp (App (Lam x (Add (Var x) (Var x))) big_computation) []
 When the first variable x is evaluated my interp function returns the
 value and the updated environment. Then to evaluate the second variable
 the value is just looked up from this environment.
 Of course in the following big_computation would be evaluated twice
 (App (Lam x (App (Lam y (Add (Var x) (Var y))) big_computation))
 big_computation)
 But i simply don't have a concept like let x=y.

  App (Lam x (App (Lam y (Add (Var y) (Var x))) (Var x ))) (Con 2)

 takes three reduction steps, which is correct, but

  App (Lam x (App (Lam y (Add (Var y) (Var x))) (Var x ))) (Add (Con 
 1)(Con 1))

 takes five reduction steps although it should take only four.
Ok, I now see the problem. Thanks for pointing it out to me.

 And that is why I say never return an environment. It is either wrong or 
 unnecessary or the resulting semantics of the interpreter is hard to 
 comprehend.

 In order to implement lazy evaluation correctly, you have to maintain some 
 global state in which the thunks are updated. For example, your environment 
 could bind IORefs that contain unevaluated thunks to variable names and 
 update them when the thunk is evaluated. But then your interpreter has to 
 run in the IO monad.
 I agree that this would  be the proper way to do it, but I was trying
 to minimize the use of monads since they have just been introduced in
 the course.
 That shouldn't be too hard. Just change your definition of monad M to

  newtype M a = M (State - IO (a, State))

 and define the corresponding monad instance as an exercise :) (or ask me by 
 private mail if you like).
I'll try to implement it tomorrow. Hopefully I'll succeed without your
help. ;)


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] overloading show function

2011-06-29 Thread Philipp Schneider
Hi cafe,

in my program i use a monad of the following type

newtype M a = M (State - (a, State))

i use the monad in two different ways. The type variable a can be a
pair as in

interp :: Term - Environment - M (Value,Environment)

and it can be just a value as in

type Environment = [(Name, Either Value (M Value))]

now in any case when i print the monad, i just want to print the value
and never the environment.

More specific i want to use somthing like the following

instance (Show a,Show b) = Show (M (a,b)) where
   show (M f) = let ((v,_), s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s

instance Show a = Show (M a) where
   show (M f) = let (v, s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s

however this gives me the following error message:

Overlapping instances for Show (M (Value, Environment))
  arising from a use of `print'
Matching instances:
  instance (Show a, Show b) = Show (M (a, b))
-- Defined at
/home/phil/code/haskell/vorlesung/ue09/ue09-3c3.hs:78:10-42
  instance Show a = Show (M a)
-- Defined at
/home/phil/code/haskell/vorlesung/ue09/ue09-3c3.hs:82:10-29
In a stmt of an interactive GHCi command: print it

Any ideas how to fix it? Thanks!
Philipp

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] overloading show function

2011-06-29 Thread Philipp Schneider
Thank you very much, this worked.

On 06/30/2011 12:03 AM, aditya siram wrote:
 Try enabling OverlappingInstances extension by adding this to the top
 of the file:
 {-# LANGUAGE OverlappingInstances #-}

 -deech

 On Wed, Jun 29, 2011 at 4:50 PM, Philipp Schneider
 philipp.schneid...@gmx.net wrote:
 Hi cafe,

 in my program i use a monad of the following type

 newtype M a = M (State - (a, State))

 i use the monad in two different ways. The type variable a can be a
 pair as in

 interp :: Term - Environment - M (Value,Environment)

 and it can be just a value as in

 type Environment = [(Name, Either Value (M Value))]

 now in any case when i print the monad, i just want to print the value
 and never the environment.

 More specific i want to use somthing like the following

 instance (Show a,Show b) = Show (M (a,b)) where
   show (M f) = let ((v,_), s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s

 instance Show a = Show (M a) where
   show (M f) = let (v, s) = f 0 in
 Value:  ++ show v ++   Count:  ++ show s

 however this gives me the following error message:

Overlapping instances for Show (M (Value, Environment))
  arising from a use of `print'
Matching instances:
  instance (Show a, Show b) = Show (M (a, b))
-- Defined at
 /home/phil/code/haskell/vorlesung/ue09/ue09-3c3.hs:78:10-42
  instance Show a = Show (M a)
-- Defined at
 /home/phil/code/haskell/vorlesung/ue09/ue09-3c3.hs:82:10-29
In a stmt of an interactive GHCi command: print it

 Any ideas how to fix it? Thanks!
 Philipp

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data import from octave / text file

2011-06-15 Thread Philipp Schuster

Hi,

try Numeric.Container.loadMatrix.

Regards,
Philipp


On 15.06.2011 14:59, kaffeepause73 wrote:

Hey guys,

thanks for the very quick help. The code works and looks like:
(any tips regards speed and memory usage ?)
import System.IO
import Data.Array
import Data.Packed.Matrix

parse :: String -  [[Double]] -- expects plainer syntax
parse = map (map read . words) . lines



main = do
  -- read and show plain text
  text- readFile ./log.txt
  putStrLn text

  -- read and show parsed list of lists
  putStrLn parsed list of lists
  let m = parse text
  putStrLn (show m)

  -- convert to matrix and show
  let a = fromLists m
  putStrLn (show a)

  -- cuts out first row to get signal
  let t = takeColumns 1 a
  putStrLn (show t)

  putStrLn Finish



--
View this message in context: 
http://haskell.1045720.n5.nabble.com/Data-import-from-octave-text-file-tp4490870p4491136.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Possibility to port vshaskell to VS2008?

2008-01-13 Thread Philipp Riemer
Because my university is in the MSNDAA-program I could download the new
Visual Studio 2008 Professional, what I've done today. Now I tried to
install the vshaskell-extension to start learning Haskell but the installer
only quits with the message that (of course) VS2005 is not installed. Now is
my question if I have to download the old VS2005 or if it is somehow
possible to get this extension running with VS9.0?

I already tried to use the EclipseFP-plugin so I already have (win)hugs, ghc
and haddoc installed (if it helps for the problem above). 

The problem with this plugin was that Ctrl+Space does apparently not work
for code hints and because I'm just started to learn the language, I don't
know every keyword... So I have to look it up everytime somewhere, I want to
implement something new. The fact that Prelude.hs and others are plain text
are a great help, but what I have seen in the screenshot at
http://www.haskell.org/visualhaskell/screenshots.html would be much
better...

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-07 Thread Philipp N.


oleg-7 wrote:
 
 
 In fact, that distinction is possible. The following article
 
   How to write an instance for not-a-function
   http://okmij.org/ftp/Haskell/typecast.html#is-function-type
 
 specifically describes a method of writing an instance which is
 selected only when the type in question is NOT a function. The method
 is quite general and has been extensively used (for example, to
 implement deep monadic join).
 
 

That's really incredible, and yet I don't quite understand how IsFunction
works.
Here is my very short but powerful solution (nary is renamed to wrap).
http://www.nabble.com/file/p14220591/wrap.hs wrap.hs 

-- 
View this message in context: 
http://www.nabble.com/distinguish-functions-from-non-functions-in-a-class-instances-tf4952209.html#a14220591
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-06 Thread Philipp N.



Ryan Ingram wrote:
 
 No, that doesn't work; it's close, but not quite.  liftM doesn't have the
 right type signature.
 
 liftM :: Monad m = (a - r) - (m a1 - m r)
 
 What would work is if you could define a function
 liftLast :: Monad m = (a0 - a1 - ... - aN - r) - (a0 - a1 - ... -
 aN - m r)
 
 then
 
 nary' f = runIdentity . nary (liftLast f)
 
   -- ryan
 
 

I don't see a way to implement liftLast or nary for functions like (a - b
- ... - r) where r is not of the form (m s).

Of course one can use the Identity Monad for m, but in either case you have
to modify functions like (Int - Int) to something like (Int - m Int) for a
fixed type m (e.g. Identity).

  -- philipp n.
-- 
View this message in context: 
http://www.nabble.com/distinguish-functions-from-non-functions-in-a-class-instances-tf4952209.html#a14208302
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Philipp N.

Hello,

i'm trying to wrap functions (a - b - ... - z) of any arity to functions
of type ([String] - y), where list of strings replaces the typed arguments.

one attempt looks like this (here written with type families, you can
replace it by functional dependencies or what ever):

type family Res x
type instance Res x = x
type instance Res (x-y) = Res y

class Nary x where
nary :: x - [String] - Res x

instance Nary x where
nary x [] = x

instance Nary (x-y) where
nary f (x:xs) = nary (f $ read x) xs

i hope you can get the idea.
the problem is, that you cannot distinguish type (x-y) from z, so these
instances are overlapping.
the odd thing is. you can get this to work, if you have a terminating type
as result type (for example (IO x)). then you can work with all types (IO
x), (a - IO x), (a - b - IO x), ...

but i don't want this delimiter IO! any ideas?

greetings
  Philipp N.

-- 
View this message in context: 
http://www.nabble.com/distinguish-functions-from-non-functions-in-a-class-instances-tf4952209.html#a14180315
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Coding Standards (Coding Conventions)

2007-05-28 Thread Philipp Volgger
I wonder if there are any Coding Standards or Coding Conventions for 
Haskell. Does anybody know something about it?


Kind regards,
Philipp Volgger

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Random idea

2007-05-20 Thread Philipp Volgger


For me it gives:
 1 + 1
Maybe you meant: . v

But the rest of the commands seems working ;)



Andrew Coppin schrieb:

Rodrigo Queiro wrote:

http://lambdabot.codersbase.com/


Wait, what the hell...?


 1 + 1
/usr/lib/ghc-6.4.2/package.conf: openFile: does not exist (No such 
file or directory)


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problems with Hs-Plugins

2007-05-05 Thread Philipp Volgger

I tried following very simple program:

module Main where
import System.Eval.Haskell

main = do i - eval 1 + 6 :: Int [] :: IO (Maybe Int)
  if isJust i then putStrLn (show (fromJust i)) else return ()

I compile it with ghc -c Main.hs and everything seems fine.
When I run it with ghc Main.o I get following message:
Main.o(.text+0x48):fake: undefined reference to 
`AltDataziTypeable_zdfTypeableInt_closure'
Main.o(.text+0x4d):fake: undefined reference to 
`SystemziEvalziHaskell_eval_closure'
Main.o(.text+0x36f):fake: undefined reference to 
`__stginit_SystemziEvalziHaskell_'
Main.o(.rodata+0x0):fake: undefined reference to 
`SystemziEvalziHaskell_eval_closure'
Main.o(.rodata+0x4):fake: undefined reference to 
`AltDataziTypeable_zdfTypeableInt_closure'

collect2: ld returned 1 exit status

When I run it with runhaskell Main I get:



GHCi runtime linker: fatal error: I found a duplicate definition for 
symbol

   _GHCziWord_fromEnum1_closure
whilst processing object file
   c:/ghc/ghc-6-4-2/ghc-6.4.2/HSbase1.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
 loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.

So I did probably something totally wrong, but what?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Is Hs-Plugins dead?

2007-05-01 Thread Philipp Volgger
Is Hs-Plugins still under develeopment; is there still somebody who is 
updating it?



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] FIT for Haskell

2007-04-30 Thread Philipp Volgger
Who wrote FIT for Haskell on http://darcs.haskell.org/FIT/? Does anybody 
know if the version is stable?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] IDE support

2007-04-22 Thread Philipp Volgger
What IDE support is available for Haskell (Visuall Haskell, EclipseFP), 
anything else?



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Installation of hs-plugins

2007-04-21 Thread Philipp Volgger
I now used GHC 6.4 and mingw ( MSYS-1.0.11 ). Now it is possible to 
configure, build and install it. But on running the test ( out of a 
email from the list, source code see below) it crashes again without any 
information.

I compiled the Test1.hs with ghc -c Test1.hs.


Bayley, Alistair wrote:
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Philipp Volgger


could somebody please tell me how hs-plugins has to be installed. I 
tried it with hs-plguin 1.0rc1 and I was unable to build it. I did

runhaskell Setup.lhs configure
runhaskell Setup.lhs build   (Crash without any information)
I tried it wiht GHC 6.4, 6.4.1 and 6.6.

I am using Windows XP with SP2.



I'm pretty sure you need to install under some kind of bash shell. I
used mingw on WinXP, but I think it can be done with cygwin. I'd
recommend mingw if you don't have either installed.

Note that hs-plugins doesn't work with ghc-6.6 yet on Windows, so stick
with 6.4.1 if you can.

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*

  


Test:

module Test1 where
test1 = putStrLn test1


module Main where
import Prelude hiding (catch)
import Control.Exception
import Data.List
import System.Environment
import System.Plugins

instance Show (LoadStatus a) where
 show (LoadFailure errors) = LoadFailure -  ++ (concat (intersperse
\n errors))
 show (LoadSuccess m p) = LoadSuccess

main = do
 a - getArgs
 let
   modName = case a of
 (n:_) - n
 _ - Test1
 let modPath = ./ ++ modName ++ .o
 let method = test1
 fc - catch (load modPath [] [] method)
   (\e - return (LoadFailure
 [Dynamic loader returned:  ++ show e]))
 case fc of
   LoadFailure errors - do
 fail (concat (intersperse \n errors))
   LoadSuccess modul proc - do
 let p :: IO (); p = proc
 proc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Installation of hs-plugins

2007-04-20 Thread Philipp Volgger

Hello everybody,

could somebody please tell me how hs-plugins has to be installed. I 
tried it with hs-plguin 1.0rc1 and I was unable to build it. I did

   runhaskell Setup.lhs configure
   runhaskell Setup.lhs build   (Crash without any information)
I tried it wiht GHC 6.4, 6.4.1 and 6.6.

I am using Windows XP with SP2.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Function call by string

2007-04-08 Thread Philipp Volgger

Hello everybody!
Can me somebody say how I can call a function by string? Thus I want to 
have a function that has as argument a string (name of a function to 
call) and then tries to call that function, a kind of:


functionCall :: String - [String] - RetVal
functionCall functionName arguments = ...

Thanks
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Function call by string

2007-04-08 Thread Philipp Volgger
Well, the Haskell files are not the problem, they don't have to be built 
automatically. The point is that I want to call functions in a Haskell 
function if I get their names as strings. Isn't there any possibilty to 
do that? Eventually the interpreter reads also the console in to execute 
the input. Maybe it will be the best to look there (interpreter code of 
GHCi)


Thank you :)

Lennart Augustsson schrieb:
It sounds like you need to generate some kind of Haskell stubs given 
the Java signatures.


On Apr 8, 2007, at 11:16 , Philipp Volgger wrote:

Well my problem is the following. I try to make Haskell work with FIT 
for Java. I would like to have a 1-to-1 corresondence between the 
Java methods and the functions in the corresponding module in 
Haskell, thus they would have to have the same name and 
arguments/parameters. From Java I could then run the Haskell Code (by 
a Server), but I would like to have the possiblity to name the 
module, the functionname and so on.



Lennart Augustsson schrieb:
In general, you can't do that.  You can only do it if you restrict 
the functions that can be called somehow, e.g., by having a list of 
callable functions and their names.


Why do you want to do this?  Perhaps there is a more Haskelly 
solution to your problem.


-- Lennart

On Apr 8, 2007, at 11:01 , Philipp Volgger wrote:


Hello everybody!
Can me somebody say how I can call a function by string? Thus I 
want to have a function that has as argument a string (name of a 
function to call) and then tries to call that function, a kind of:


functionCall :: String - [String] - RetVal
functionCall functionName arguments = ...

Thanks
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe








___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe