[Haskell] build an interpreter on top of GHCi?

2005-01-26 Thread WANG Meng
Hi All, Does anybody has the experience to built an interpreter on top of GHCi? What I want is to defined a my own interpreter as a Haskell module and load it into GHCi. So this new interpreter will be running on top of GHCi which accepts syntax extension of Haskell. For example: Prelude> :l myI

[Haskell] parser for "Typing Haskell in Haskell"

2004-11-17 Thread WANG Meng
Hi All, Does anybody know what parser "Typing Haskell in Haskell" use? I am tring to use the code for some type checking. But I cannot find a parser in the distribution. -W-M- @ @ | \_/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.hask

constrained datatype

2004-01-14 Thread Wang Meng
Hi All, Anybody knows why the following code does not work? > class Foo n > data Erk n = Foo n => Erk test.hs:53: All of the type variables in the constraint `Foo n' are already in scope (at least one must be universally quantified here) When checking the existential context of

import modules from a different directory

2003-12-11 Thread Wang Meng
Hi All, Anybody has the experience of importing a module from a different directory?In my code, i need to import a module that is not in the current directory. How can I do that in GHC? -W-M- @ @ | \_/ ___ Haskell mailing list [EMAIL PROTECTED

Re: *safe* coerce, for regular and existential types

2003-08-01 Thread Wang Meng
I admire the elegancy of your code which makes the changes to add new data types minimum. There is one question I want to ask: Does this technique extend to polymophic types? Let's say we have the following type: > data D a = C | D a Is it possible to index the type D a? Or there is some fundmen

dynamics on polymorphic datatype

2003-07-25 Thread Wang Meng
Hi All, I am trying to perform dynamic casting on polymorphic types. Let's say I have a data type like: > data Foo a = Foo a Is there any way to use dynamics to convert a value of type Foo a to a type reprentation? I try to use the toDyn in the dynamic libray, it complains for ambigours a. Is th

polymorphic type in state of state monad

2003-03-10 Thread Wang Meng
Hi All, Any one of your have the experience of defining a state of a state monad as a polymorphic type? I want to have: > type State = Term a => [a] > data M a = M (State -> IO(State,a)) GHC yields a error message "Illegal polymorphic type". How to resolve this? Thank you very much. -W-M-

overload lift function

2003-03-06 Thread Wang Meng
Hi All, I have a data type defined as > data D a = D1 Int | D2 a Follow this definition, I have D2 Int,D2 Bool and D2 [D2 Int] as instances of type D. I want to write an overloaded function lift which lifts an atom type to D. It is easily done for D2 Int and D2 Bool using type classes.I can h

Re: int to float problem

2003-02-28 Thread Wang Meng
Try intToFloat :: Int -> Float intToFloat n = fromInteger (toInteger n) -W-M- @ @ | \_/ On Fri, 28 Feb 2003, Mike T. Machenry wrote: > Hello, > > I am having a problem. I recently desided I wanted a bunch function to return > float instead of Int. I changed their type and wro

escape from existential quantification

2003-02-27 Thread Wang Meng
I understand that existentially bound types cannot escape. For example, say we have data Foo = forall a. Foo Int a Then we cannot define a function extract (Foo i a) = a However,this limitation makes it extremly difficult to program with local quantifications.Is there any way to by pass this?