Re: [Haskell-cafe] A question regarding reading CPP definitions from a C header
Thanks for your answer, looks like this is my only option to do this. Can you provide some information about what does parameters of runCpphsReturningSymTab stands for? I made several attempts but couldn't get any useful return value. For example, I have no idea what does third parameter does. Also, second parameter. Thanks, --- Ömer Sinan Ağacan http://osa1.net 2013/10/7 Malcolm Wallace malcolm.wall...@me.com: If you use cpphs as a library, there is an API called runCpphsReturningSymTab. Thence you can throw away the actual pre-preprocessed result text, keep only the symbol table, and lookup whatever macros you wish to find their values. I suggest you make this into a little code-generator, to produce a Haskell module containing the values you need. On 5 Oct 2013, at 21:37, Ömer Sinan Ağacan wrote: Hi all, Let's say I want to #include a C header file in my Haskell library just to read some macro definitions. The C header file also contains some C code. Is there a way to load only macro definitions and not C code in #include declarations in Haskell? What I'm trying to do is I'm linking my library against this C library but I want to support different versions of this C library, so I want to read it's version from one of it's header files. The problem is the header file contains some C code and makes my Haskell source code mixed with C source before compilation. Any suggestions would be appreciated, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A question regarding reading CPP definitions from a C header
Carl, thank you very much. This is exactly what I was looking for, and it solved my problem in 5 minutes. What's awesome is that when Cabal finds a .hsc file it automatically calls this tool. Great. Thanks again. --- Ömer Sinan Ağacan http://osa1.net 2013/10/8 Carl Howells chowell...@gmail.com: Have you looked into using hsc2hs? If I understand your problem, it's designed exactly to solve it. -- Carl On Mon, Oct 7, 2013 at 12:20 PM, Ömer Sinan Ağacan omeraga...@gmail.com wrote: Thanks for your answer, looks like this is my only option to do this. Can you provide some information about what does parameters of runCpphsReturningSymTab stands for? I made several attempts but couldn't get any useful return value. For example, I have no idea what does third parameter does. Also, second parameter. Thanks, --- Ömer Sinan Ağacan http://osa1.net 2013/10/7 Malcolm Wallace malcolm.wall...@me.com: If you use cpphs as a library, there is an API called runCpphsReturningSymTab. Thence you can throw away the actual pre-preprocessed result text, keep only the symbol table, and lookup whatever macros you wish to find their values. I suggest you make this into a little code-generator, to produce a Haskell module containing the values you need. On 5 Oct 2013, at 21:37, Ömer Sinan Ağacan wrote: Hi all, Let's say I want to #include a C header file in my Haskell library just to read some macro definitions. The C header file also contains some C code. Is there a way to load only macro definitions and not C code in #include declarations in Haskell? What I'm trying to do is I'm linking my library against this C library but I want to support different versions of this C library, so I want to read it's version from one of it's header files. The problem is the header file contains some C code and makes my Haskell source code mixed with C source before compilation. Any suggestions would be appreciated, ___ 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] A question regarding reading CPP definitions from a C header
Hi all, Let's say I want to #include a C header file in my Haskell library just to read some macro definitions. The C header file also contains some C code. Is there a way to load only macro definitions and not C code in #include declarations in Haskell? What I'm trying to do is I'm linking my library against this C library but I want to support different versions of this C library, so I want to read it's version from one of it's header files. The problem is the header file contains some C code and makes my Haskell source code mixed with C source before compilation. Any suggestions would be appreciated, Thanks, --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] starting GHC development -- two questions
Hi all, I want to start working on GHC, I cloned the repo, made some trivial changes(change some strings etc.) and re-built and observed the results. Now I'll continue reading and understanding the source. While doing this, I think one feature would greatly help me finding my way through GHC source, which is huge: I want to see definition of some symbols. Normally what I would do for this is to load source into GHCi and run :info command. But in the case of GHC, even if it's possible to load GHC into GHCi, I don't think it will be faster than running ack --haskell someSymbol and searching through results manually. First idea came to my mind was to generate tags files and then navigate from within vim(my editor of choice). tags file can be added to Makefile as a goal and then tags can be regenerated after each build. Did anyone else try this before? My second question is do we have any low-hanging fruits in trac, to help new people start contributing to GHC? I know several open source projects using that approach and it's really helpful for beginners. I just skimmed over trac and most issues look way too advanced for a starter. Thanks in advance, --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] starting GHC development -- two questions
Hello Edward, First off, welcome to the wonderful world of GHC development! I recommend that you subscribe to the ghc-devs mailing list and direct GHC specific questions there: http://www.haskell.org/mailman/listinfo/ghc-devs Thanks, I didn't know that. I subscribed and I will ask further questions to that list. GHC has a 'make tags' command but I've never gotten it to work. I have always just run 'hasktags .' in the compiler/ directory, which works pretty well for me. (If you're in the RTS, run ctags, etc instead) Great! It worked at the first try and I already started using it. We've been discussing putting together an easy bugs list. As a proxy, you can search on the 'Difficulty' keyword: http://ghc.haskell.org/trac/ghc/query?status=infoneededstatus=mergestatus=newstatus=patchdifficulty=Easy+(less+than+1+hour)col=idcol=summarycol=statuscol=typecol=prioritycol=milestonecol=componentorder=priority For example, this bug seems like a good beginner bug to get your feet wet with the RTS: http://ghc.haskell.org/trac/ghc/ticket/750 This one will give you some experience wrangling the test suite: http://ghc.haskell.org/trac/ghc/ticket/8079 Moving up to the moderate category, here is a nontrivial bug involving profiling and the optimizer: http://ghc.haskell.org/trac/ghc/ticket/609 As with all open source projects, there is always lots of infrastructural work to be done, so if that's your sort of thing, there are plenty of bugs in that category. Thanks, I'll start looking for issues with easy difficulty for now and ask further questions to ghc-devs mailing list. --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] same function's type accepted in top level, but rejected in where clause
Hi all, I came across an interesting type checker error, a function is accepted in top level, but rejected by type checker when moved to `where ...` clause. I moved required code to a new module for demonstration purposes: module Bug where fix :: (a - a) - a fix f = let x = f x in x data Fix f = Fix (f (Fix f)) unFix :: Fix f - f (Fix f) unFix (Fix a) = a data ListF a l = NilF | ConsF a l instance Functor (ListF a) where fmap _ NilF= NilF fmap f (ConsF a l) = ConsF a (f l) fold :: Functor f = (f a - a) - Fix f - a fold f a = f (fmap (fold f) (unFix a {- f (Fix f) -})) unfold :: Functor f = (a - f a) - a - Fix f unfold f a = Fix (fmap (unfold f) (f a)) Now, after this code, type checker accept this function: iterateListF :: (a - a) - a - Fix (ListF a) iterateListF fn e = unfold (foldFn fn) e foldFn :: (a - a) - a - ListF a a foldFn fn a = ConsF a (fn a) But rejects this: iterateListF :: (a - a) - a - Fix (ListF a) iterateListF fn e = unfold f e where f :: a - ListF a a f a = ConsF a (fn a) With error: bug.hs:27:20: Couldn't match expected type `a1' with actual type `a' `a1' is a rigid type variable bound by the type signature for f :: a1 - ListF a1 a1 at bug.hs:26:10 `a' is a rigid type variable bound by the type signature for iterateListF :: (a - a) - a - Fix (ListF a) at bug.hs:23:17 In the return type of a call of `fn' In the second argument of `ConsF', namely `(fn a)' In the expression: ConsF a (fn a) Changing type variables in type of `f` to `x` fails with this error: bug.hs:28:20: Couldn't match expected type `x' with actual type `a' `x' is a rigid type variable bound by the type signature for f :: x - ListF x x at bug.hs:27:10 `a' is a rigid type variable bound by the type signature for iterateListF :: (a - a) - a - Fix (ListF a) at bug.hs:24:17 In the return type of a call of `fn' In the second argument of `ConsF', namely `(fn a)' In the expression: ConsF a (fn a) Failed, modules loaded: none. .. and this is strange because error message describes function as it is before changing `a` to `x`. Any ideas why this definition rejected? Is this a bug in GHC? --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] same function's type accepted in top level, but rejected in where clause
If you add the pragma ScopedTypeVariables to your file, it works the way you would assume. However you will have to change the toplevel signature to iterateListF :: forall a. (a - a) - a - Fix (ListF a) in order to make it work (added the forall a.). Thanks, that worked. As far as I understand, the problem is because in this definition: where f :: a - ListF a a f a = ConsF a (fn a) There's an implicit quantifier in type of `f`, like this: `f :: forall a. a - ListF a a`. When I add `ScopedTypeVariables` and `forall a. ...` in top level definition, it's like all `a`s in scope of top level definition are same, except when explicitly defined as `forall a. ...`. Is my intuition correct? --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal-dev: installing/running with profiling enabled
Hi Rogan, Thanks for your reply. I don'th think the -prof flag is necessary; but if it is, then it may also be misinterpreted by cabal-dev; generally, you need to pass flags that only use a single leading - to cabal-dev with the --flags=... option. (eg: 'cabal-dev install --enable-library-profiling --enable-executable-profiling --flags=-prof' This command worked for me: $ cabal-dev install --enable-library-profiling --enable-executable-profiling OK, so I removed `cabal-dev` directory, and installed again with this command. But it still failed with same error message(the flag -p requires the program to be built with -prof). Then I also tried removing cabal-dev again and installing again but this time with extra `--flags=-prof` parameter. Failed with same error. Just to be sure I created a new cabal project with only one file: 'Hello.hs' with contents 'main = putStrLn hello' and tried to install it with cabal-dev. And `./cabal-dev-/bin/Hello +RTS -p` failed with same error again. Maybe something wrong with my system? My first thought was maybe cabal-dev is using some pre-installed library, and it's not recompiling the whole world for each sandbox. But I don't know how to check this. Any ideas on that? Thanks, --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal-dev: installing/running with profiling enabled
Maybe you are running into this: https://github.com/haskell/cabal/issues/1199 Check your version of the Cabal library (cabal --version should tell you). I think this was only broken for a few releases, but I don't remember which ones. Great, it worked. I first updated Cabal library (with `cabal install cabal`) and cabal-install program(`cabal install cabal-install`) and then reinstalled cabal-dev. Now it works for my hello world program. Hopefully it will also work with my main program(it's compiling now, and it will take some time). Thanks! --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal-dev: installing/running with profiling enabled
Hi all, I want to profile a Haskell program. I have tons of libraries installed without profiling enabled, and some of them are installed with my Linux distribution's package mangaer. So I tried installing the program in a fresh cabal-dev environment with profiling enabled, so that all dependencies would be also installed with profiling enabled. But for some reason even after installing with `cabal-dev install --enable-executable-profiling -prof` I still can't run this program with `caba-dev/bin/program +RTS -p`, it fails with 'program: the flag -p requires the program to be built with -prof'. Can anyone help me on installing/running in cabal-dev with profiling enabled? --- Ömer Sinan Ağacan http://osa1.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is there an escape from MonadState+MonadIO+MonadError monad stack?
Hi, I'm a hobbyist Haskell programmer and my use of Haskell is mostly consists of writing interpreters, simple virtual machines, and type checkers. One thing I'm not happy about my Haskell programs is, almost all of my programs have a monad transformer stack consisting MonadError, MonadIO and MonadState. Let's say I'm writing an interpreter, I certainly need MonadIO to interpret object language's IO functions: printing, reading from file etc. I also need MonadState for, well, states(dynamic environment etc.). MonadError is also required because most computations can fail(unbound variable error, type mismatch etc. it can be also used for implementing exceptions in object language) Same applies for my other applications as well. Type checkers require MonadError(unification error etc.), MonadState(to keep substitutions). MonadIO is not required in this case. But it also required for virtual machines(IOVector for memory -- ST vectors also work, but IO is still required for other stuff - printing, display etc.) I know these are mostly related with my application area, but I still wanted to write this because I may be missing something, or simply doing things wrong. Advices from experienced Haskell programmers would be appreciated, Cheers, Ömer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there an escape from MonadState+MonadIO+MonadError monad stack?
You forgot to mention what your problem is. :) What you describe sounds reasonable. Why do you want to escape? It's not really a problem, I'm not happy with this design because to me it was like I'm missing the point of using a 'functional' language. For instance, in most parts of my code I can actually do IO. On the other hand, I know it's mostly because of my application area and nothing to do with Haskell. Let's say I just wanted to know ideas of experienced Haskell programmers :-) Ömer --- Ömer Sinan Ağacan http://osa1.net/ 2013/4/7 Roman Cheplyaka r...@ro-che.info: Hi Ömer, You forgot to mention what your problem is. :) What you describe sounds reasonable. Why do you want to escape? Roman * Ömer Sinan Ağacan omeraga...@gmail.com [2013-04-07 00:22:58+0300] Hi, I'm a hobbyist Haskell programmer and my use of Haskell is mostly consists of writing interpreters, simple virtual machines, and type checkers. One thing I'm not happy about my Haskell programs is, almost all of my programs have a monad transformer stack consisting MonadError, MonadIO and MonadState. Let's say I'm writing an interpreter, I certainly need MonadIO to interpret object language's IO functions: printing, reading from file etc. I also need MonadState for, well, states(dynamic environment etc.). MonadError is also required because most computations can fail(unbound variable error, type mismatch etc. it can be also used for implementing exceptions in object language) Same applies for my other applications as well. Type checkers require MonadError(unification error etc.), MonadState(to keep substitutions). MonadIO is not required in this case. But it also required for virtual machines(IOVector for memory -- ST vectors also work, but IO is still required for other stuff - printing, display etc.) I know these are mostly related with my application area, but I still wanted to write this because I may be missing something, or simply doing things wrong. Advices from experienced Haskell programmers would be appreciated, Cheers, Ömer ___ 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] Is there an escape from MonadState+MonadIO+MonadError monad stack?
Not as well-known as it should be is the fact that GHC doesn't make much use of monad transformers. Have you taken a look at the sources? That might provide ideas on future ways of structuring your experiments. That's interesting, thanks! Do you have any recommendations about which file to start reading? AFAIK, GHC is _huge_. Ömer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: language-java 0.2.0
Great, thanks for this great work! One of the things I _love_ about haskell and it's community is that language-x packages. I really love playing with source code and compiling to other languages. And working with Haskell, thanks to that language-x packages, make this a joy. And recently I also wrote one, language-lua: http://hackage.haskell.org/package/language-lua . Maybe I should write an announcement mail too :-) . --- Ömer Sinan Ağacan 2012/11/27 Vincent Hanquez t...@snarc.org On 11/27/2012 06:46 PM, Alfredo Di Napoli wrote: Thanks for the effort! Now, what about some documentation? :P Sure ! Fork away, and send pull requests :-) -- Vincent __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe