Re: [Haskell-cafe] Non-recursive let [Was: GHC bug? Let with guards loops]

2013-07-12 Thread Andreas Abel

On 12.07.2013 02:22, Richard A. O'Keefe wrote:

For what it's worth,


let x = 1 in

-   let x = x+1 in
- let x = x+2 in
-   x;;

prints

val it : int = 4

in the F# interactive system, but


let x = 1 in

- let x = x+1 in
- let x = x+2 in
-   x;;

prints Duplicate definition of x at the second line.


Since silverlight does not work properly on my systems, I cannot 
tryfsharp.org.  I can try ocaml, which does not use indentation, and 
there the value is 4, and there is no ambiguity at all.


  let p = e in body

is just

  (\ p - body) e

it cannot be simpler than that.  So I do not see your point.

--
Andreas AbelDu bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.a...@ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/

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


[Haskell-cafe] Quick-check: how to generate arbitrary complex data?

2013-07-12 Thread martin
Hello all,

I have a type (Mail) which consists of hash and a list, where the hash
keeps some redundant data of the list for faster access. I can add and
remove elements to values of this type using custom functions, called
push and pop.

Now I wanted to write some quick checks, but I have no clue how to
generate arbitrary values of this type. It will certainly no suffice to
write arbitrary instances for the underlying types (Int and Char),
because the hash and the list need to be synchronized.

Currently Mail it is only a type synonym. I suppose as a prerequisite
I need to wrap it into a type constructor. But then what?

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


Re: [Haskell-cafe] Quick-check: how to generate arbitrary complex data?

2013-07-12 Thread Roman Cheplyaka
* martin martin.drautzb...@web.de [2013-07-12 08:33:54+0200]
 Hello all,
 
 I have a type (Mail) which consists of hash and a list, where the hash
 keeps some redundant data of the list for faster access. I can add and
 remove elements to values of this type using custom functions, called
 push and pop.
 
 Now I wanted to write some quick checks, but I have no clue how to
 generate arbitrary values of this type. It will certainly no suffice to
 write arbitrary instances for the underlying types (Int and Char),
 because the hash and the list need to be synchronized.
 
 Currently Mail it is only a type synonym. I suppose as a prerequisite
 I need to wrap it into a type constructor. But then what?

QuickCheck's Gen is a functor. So you can generate a list, and then
use fmap to add a hash to it.

  instance Arbitrary HashedList where
arbitrary = addHashToList $ arbitrary

Roman

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


Re: [Haskell-cafe] How to use cabal-dev ghci and multiple targets/build-depends from cabal file?

2013-07-12 Thread Kirill Zaborsky
It looks like cabal repl [1] could solve this kind of problems, but it is 
not clear when it will be merged in cabal HEAD.

[1] https://github.com/haskell/cabal/issues/375

KInd regards,
Kirill Zaborsky

четверг, 11 июля 2013 г., 15:55:15 UTC+4 пользователь Kirill Zaborsky 
написал:

 Currently I'm creating a small library and I wanted to create tests for 
 it. So I have a library section in cabal file and also a test-suite section.

 Everything goes well but when I tried to load file with tests into ghci 
 (actually it was a REPL in emacs) I received errors stating that GHCi can 
 not find e.g. Test.Framework module.

 Is there any way to use multiple build-depends in GHCi?

 KInd regards,
 Kirill Zaborsky

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


Re: [Haskell-cafe] Comparing functions

2013-07-12 Thread Vlatko Basic
Thanks Roman. Tried it and implemented, but had troubles until I realized that 
for String, 10 test take quite long. :-)


However, I decided to solve this problem in a more natural way


 Original Message  
Subject: Re: [Haskell-cafe] Comparing functions
From: Roman Cheplyaka r...@ro-che.info
To: Vlatko Basic vlatko.ba...@gmail.com
Cc: Haskell-Cafe haskell-cafe@haskell.org
Date: 11.07.2013 20:10


* Vlatko Basic vlatko.ba...@gmail.com [2013-07-11 19:33:38+0200]

Hello Cafe,

I have

 data CmpFunction a = CF (a - a - Bool)

that contains comparing functions, like ==, ,  ..., and I'm trying
to declare the Show instance for it like this

 instance Show (CmpFunction a) where
   show (CF (==)) = ==-- no good
   show f = case f of-- no good also
CBF (==) - ==
 _ - Other

but compiler complains for both with

This binding for `==' shadows the existing binding
imported from `Prelude' at src/Main.hs:6:8-11
(and originally defined in `ghc-prim:GHC.Classes')

Is it possible at all to compare two functions or how to solve this
problem, to show some string for a specific function?


Depending on why you need that...

   {-# LANGUAGE FlexibleContexts, UndecidableInstances, FlexibleInstances #-}
   import Test.SmallCheck
   import Test.SmallCheck.Series
   import Test.SmallCheck.Drivers
   import Control.Monad.Identity
   import Data.Maybe

   data CmpFunction a = CF (a - a - Bool)

   feq :: (Show a, Serial Identity a) = CmpFunction a - CmpFunction a - Bool
   feq (CF f1) (CF f2) =
 isNothing $
   runIdentity $
 smallCheckM 10 (\x1 x2 - f1 x1 x2 == f2 x1 x2)

   instance Show (CmpFunction Integer) where
 show f
   | f `feq` CF (==) = ==
   | f `feq` CF (/=) = /=
   | f `feq` CF ()  = 
   | f `feq` CF (=)  = =
   | otherwise = Unknown function

This uses SmallCheck to figure out, with some degree of certainty,
whether two functions are equal.

Of course, Rice's theorem still holds, and the above instance is easy
to fool, but it still might be useful in some cases.

Roman



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


[Haskell-cafe] Deriving with generics without values

2013-07-12 Thread JP Moresmau
Hello all,
My problem is the following: I have my own data types, and I'd like to
derive automatically instances of some type class from them. I've started
looking at GHC.Generics, which offer tools to do exactly that. However,
some functions of my typeclass do not take my data type as a parameter, but
as a result. Basically:
 class MyClass where
   fromString :: String - a

 data MyData=MkMyData {
   myField ::Int
 } deriving (Generic)

and I want to automatically generate the instance instance MyClass MyData,
using default methods, etc.
The GHC Generic class does say that it uses a from function that convert
from the datatype to its representation: from :: a -
Rephttp://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
a
xfrom :: a - 
Rephttp://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
a
x
But I don't have a a to start from! I see from the related papers that
the automatically generated code from from actually does pattern matches on
constructors, so I need a value, undefined won't work. However I see the
GHC.Generics also provide :+: (Sums: encode choice between constructors).
If I have to provide an value, then the choice between constructor has been
done! The examples about generics on
http://www.haskell.org/haskellwiki/GHC.Generics do provide an example of
defining the instance for :+: but I don't understand how we can get there.
If I have a class method that takes a value as a parameter, and I pass
undefined to it, the code will crash, since it can't pattern match on
undefined.

Can somebody shed some light on this? Am I using the wrong tool for the
job? How can I achieve what I want? I want the full type representation
with sums, but without a value to start from.

Thanks a million!

JP
-- 
JP Moresmau
http://jpmoresmau.blogspot.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Deriving with generics without values

2013-07-12 Thread Roman Cheplyaka
Well, in your case, you need not 'from', but 'to', in order to convert
from a generic representation to yours.

Take a look at how a similar task is done in SmallCheck:
https://github.com/feuerbach/smallcheck/blob/master/Test/SmallCheck/Series.hs#L180
https://github.com/feuerbach/smallcheck/blob/master/Test/SmallCheck/Series.hs#L352

Roman

* JP Moresmau jpmores...@gmail.com [2013-07-12 10:45:39+0200]
 Hello all,
 My problem is the following: I have my own data types, and I'd like to
 derive automatically instances of some type class from them. I've started
 looking at GHC.Generics, which offer tools to do exactly that. However,
 some functions of my typeclass do not take my data type as a parameter, but
 as a result. Basically:
  class MyClass where
fromString :: String - a
 
  data MyData=MkMyData {
myField ::Int
  } deriving (Generic)
 
 and I want to automatically generate the instance instance MyClass MyData,
 using default methods, etc.
 The GHC Generic class does say that it uses a from function that convert
 from the datatype to its representation: from :: a -
 Rephttp://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
 a
 xfrom :: a - 
 Rephttp://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
 a
 x
 But I don't have a a to start from! I see from the related papers that
 the automatically generated code from from actually does pattern matches on
 constructors, so I need a value, undefined won't work. However I see the
 GHC.Generics also provide :+: (Sums: encode choice between constructors).
 If I have to provide an value, then the choice between constructor has been
 done! The examples about generics on
 http://www.haskell.org/haskellwiki/GHC.Generics do provide an example of
 defining the instance for :+: but I don't understand how we can get there.
 If I have a class method that takes a value as a parameter, and I pass
 undefined to it, the code will crash, since it can't pattern match on
 undefined.
 
 Can somebody shed some light on this? Am I using the wrong tool for the
 job? How can I achieve what I want? I want the full type representation
 with sums, but without a value to start from.
 
 Thanks a million!
 
 JP
 -- 
 JP Moresmau
 http://jpmoresmau.blogspot.com/

 ___
 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] Deriving with generics without values

2013-07-12 Thread JP Moresmau
Yes, this looks like a similar task, thanks a million!

JP


On Fri, Jul 12, 2013 at 10:57 AM, Roman Cheplyaka r...@ro-che.info wrote:

 Well, in your case, you need not 'from', but 'to', in order to convert
 from a generic representation to yours.

 Take a look at how a similar task is done in SmallCheck:

 https://github.com/feuerbach/smallcheck/blob/master/Test/SmallCheck/Series.hs#L180

 https://github.com/feuerbach/smallcheck/blob/master/Test/SmallCheck/Series.hs#L352

 Roman

 * JP Moresmau jpmores...@gmail.com [2013-07-12 10:45:39+0200]
  Hello all,
  My problem is the following: I have my own data types, and I'd like to
  derive automatically instances of some type class from them. I've started
  looking at GHC.Generics, which offer tools to do exactly that. However,
  some functions of my typeclass do not take my data type as a parameter,
 but
  as a result. Basically:
   class MyClass where
 fromString :: String - a
 
   data MyData=MkMyData {
 myField ::Int
   } deriving (Generic)
 
  and I want to automatically generate the instance instance MyClass
 MyData,
  using default methods, etc.
  The GHC Generic class does say that it uses a from function that convert
  from the datatype to its representation: from :: a -
  Rep
 http://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
 
  a
  xfrom :: a - Rep
 http://www.haskell.org/ghc/docs/7.4.1/html/libraries/ghc-prim-0.2.0.0/GHC-Generics.html#t:Rep
 
  a
  x
  But I don't have a a to start from! I see from the related papers that
  the automatically generated code from from actually does pattern matches
 on
  constructors, so I need a value, undefined won't work. However I see the
  GHC.Generics also provide :+: (Sums: encode choice between constructors).
  If I have to provide an value, then the choice between constructor has
 been
  done! The examples about generics on
  http://www.haskell.org/haskellwiki/GHC.Generics do provide an example of
  defining the instance for :+: but I don't understand how we can get
 there.
  If I have a class method that takes a value as a parameter, and I pass
  undefined to it, the code will crash, since it can't pattern match on
  undefined.
 
  Can somebody shed some light on this? Am I using the wrong tool for the
  job? How can I achieve what I want? I want the full type representation
  with sums, but without a value to start from.
 
  Thanks a million!
 
  JP
  --
  JP Moresmau
  http://jpmoresmau.blogspot.com/

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




-- 
JP Moresmau
http://jpmoresmau.blogspot.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Reify type

2013-07-12 Thread Jose A. Lopes
Hello everyone,

Is there a way to automatically reify a type ?
In other words, to do the following:

reifyType (LitT ...) = ConT ''LitT ...

I am using Template Haskell and I want the generated code to have
access to Type datatypes that were available to the Template Haskell
code.

Cheers,
Jose

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


Re: [Haskell-cafe] Reify type

2013-07-12 Thread Michael Sloan
Hello!

I'm not sure if this is what you're asking for, as it doesn't fit that line
of code.  'LitT' is a data constructor not a type constructor.  So instead
it'd be

reifyType (LitT ...) = ConE 'LitT ...

If this is what you're looking for, then 'lift' is what you want:
http://hackage.haskell.org/packages/archive/th-lift/latest/doc/html/Language-Haskell-TH-Lift.htmlhttp://hackage.haskell.org/packages/archive/th-lift/0.5.5/doc/html/Language-Haskell-TH-Lift.html

In particular, I recommend using this package of template haskell orphans,
rather than deriving your own: http://hackage.haskell.org/package/th-orphans

Hope that helps!
-Michael



On Fri, Jul 12, 2013 at 4:45 AM, Jose A. Lopes jabolo...@google.com wrote:

 Hello everyone,

 Is there a way to automatically reify a type ?
 In other words, to do the following:

 reifyType (LitT ...) = ConT ''LitT ...

 I am using Template Haskell and I want the generated code to have
 access to Type datatypes that were available to the Template Haskell
 code.

 Cheers,
 Jose

 ___
 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] Reify type

2013-07-12 Thread Jose A. Lopes
That's exactly what I mean!
I'll give it a try.

Thanks Michael,
Jose

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


Re: [Haskell-cafe] Reify type

2013-07-12 Thread Jose A. Lopes
Hello,

I am getting the following error message:

No instance for (Lift Type)
  arising from a use of `lift'
Possible fix: add an instance declaration for (Lift Type)

I have imported Language.Haskell.TH.Instances.
Is there anything else I have to do ?

Regards,
Jose

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


Re: [Haskell-cafe] Reify type

2013-07-12 Thread Michael Sloan
You might need to cabal update - I recently uploaded a new version to
hackage, because I realized the package was a bit out of date from the
github repo.

It works for me: https://gist.github.com/mgsloan/f9238b2272df43e53896


On Fri, Jul 12, 2013 at 5:49 AM, Jose A. Lopes jabolo...@google.com wrote:

 Hello,

 I am getting the following error message:

 No instance for (Lift Type)
   arising from a use of `lift'
 Possible fix: add an instance declaration for (Lift Type)

 I have imported Language.Haskell.TH.Instances.
 Is there anything else I have to do ?

 Regards,
 Jose

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


Re: [Haskell-cafe] Correct way to catch all exceptions

2013-07-12 Thread Michael Snoyman
When I implemented this stuff yesterday, I included `Deep` variants for
each function which used NFData. I'm debating whether I think the right
recommendation is to, by default, use the `async`/NFData versions of catch,
handle, and try, or to have them as separate functions.

I wrote up the blog post, both on the Yesod blog[1] and School of
Haskell[2]. The latter's a bit easier to use since it includes active code
snippets.

[1] http://www.yesodweb.com/blog/2013/07/catching-all-exceptions
[2]
https://www.fpcomplete.com/user/snoyberg/general-haskell/exceptions/catching-all-exceptions


On Fri, Jul 12, 2013 at 4:03 AM, John Lato jwl...@gmail.com wrote:

 I agree that how the exception was thrown is more interesting than the
 type.  I feel like there should be a way to express the necessary
 information via the type system, but I'm not convinced it's easy (or even
 possible).

 Another issue to be aware of is that exceptions can be thrown from pure
 code, so if you don't fully evaluate your return value an exception can be
 thrown later, outside the catch block.  In practice this usually means an
 NFData constraint, or some other constraint for which you can guarantee
 evaluation.

 In the past I've been pretty vocal about my opposition to exceptions.
  It's still my opinion that they do not make it easy to reason about
 exceptional conditions.  Regardless, as Haskell has them and uses them, I'd
 like to see improvements if possible.  So if anyone is exploring the design
 space, I'd be willing to participate.


 On Fri, Jul 12, 2013 at 12:57 AM, Michael Snoyman mich...@snoyman.comwrote:




 On Thu, Jul 11, 2013 at 6:07 PM, Felipe Almeida Lessa 
 felipe.le...@gmail.com wrote:

 On Thu, Jul 11, 2013 at 10:56 AM, Michael Snoyman mich...@snoyman.com
 wrote:
  The only
  approach that handles the situation correctly is John's separate thread
  approach (tryAll3).

 I think you meant tryAll2 here.  Got me confused for some time =).

 Cheers,

 --
 Felipe.


 Doh, yes, I did, thanks for the clarification.

 After playing around with this a bit, I was able to get an implementation
 of try, catch, and handle which work for any non-async exception, in monad
 transformers which are instances of MonadBaseControl (from monad-control).
 I'll try to write up my thoughts in something more coherent, likely a blog
 post.

 Michael



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


[Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Evan Laforge
So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any
file that uses it.  But if you pass --optghc=-cpp, it runs CPP on
everything, which makes it crash on any file that uses string gaps, or
happens to contain a /*.  /* is rare and easily fixed, but not string
gaps.

It looks like a workaround would be to manually inspect the files for
LANGUAGE CPP and run two haddock passes, but then I would have to get
the two passes to cooperate creating a single TOC and index.

Isn't there some way to run haddock on files that use CPP?

In the broader scheme, it seems perverse to be using CPP in the first
place.  I use it to configure imports and exports, e.g. to swap out a
driver backend on different OSes, and to export more symbols when
testing.  Would it make sense to have a haskell version of CPP that
provides only these features (e.g. just #ifdef, #else, #endif, and
#define) and leaves out the problematic C comments and backslash
expectations?

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


Re: [Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Brandon Allbery
On Fri, Jul 12, 2013 at 2:25 PM, Evan Laforge qdun...@gmail.com wrote:

 In the broader scheme, it seems perverse to be using CPP in the first
 place.  I use it to configure imports and exports, e.g. to swap out a
 driver backend on different OSes, and to export more symbols when
 testing.  Would it make sense to have a haskell version of CPP that
 provides only these features (e.g. just #ifdef, #else, #endif, and
 #define) and leaves out the problematic C comments and backslash
 expectations?


You mean http://hackage.haskell.org/package/cpphs ? (although I think it
may still do some of that stuff, it does far less than ANSI demands)

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Roman Cheplyaka
* Evan Laforge qdun...@gmail.com [2013-07-12 14:25:00-0400]
 So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any
 file that uses it.

I'm pretty sure it's not true in general.

If you click on the Source link at this haddock page:

http://hackage.haskell.org/packages/archive/smallcheck/0.6.2/doc/html/Test-SmallCheck-Series.html

you'll see that CPP is used there.

Roman

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


Re: [Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Felipe Almeida Lessa
Are you using `cabal haddock` or calling haddock manually?

Cheers,

On Fri, Jul 12, 2013 at 3:25 PM, Evan Laforge qdun...@gmail.com wrote:
 So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any
 file that uses it.  But if you pass --optghc=-cpp, it runs CPP on
 everything, which makes it crash on any file that uses string gaps, or
 happens to contain a /*.  /* is rare and easily fixed, but not string
 gaps.

 It looks like a workaround would be to manually inspect the files for
 LANGUAGE CPP and run two haddock passes, but then I would have to get
 the two passes to cooperate creating a single TOC and index.

 Isn't there some way to run haddock on files that use CPP?

 In the broader scheme, it seems perverse to be using CPP in the first
 place.  I use it to configure imports and exports, e.g. to swap out a
 driver backend on different OSes, and to export more symbols when
 testing.  Would it make sense to have a haskell version of CPP that
 provides only these features (e.g. just #ifdef, #else, #endif, and
 #define) and leaves out the problematic C comments and backslash
 expectations?

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



-- 
Felipe.

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


Re: [Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Evan Laforge
I'm calling haddock myself. Cabal might have some special magic for CPP,
when I searched for haddock CPP I got some old bugs about adding cabal
support. So presumably it's possible.
On Jul 12, 2013 1:15 PM, Felipe Almeida Lessa felipe.le...@gmail.com
wrote:

 Are you using `cabal haddock` or calling haddock manually?

 Cheers,

 On Fri, Jul 12, 2013 at 3:25 PM, Evan Laforge qdun...@gmail.com wrote:
  So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any
  file that uses it.  But if you pass --optghc=-cpp, it runs CPP on
  everything, which makes it crash on any file that uses string gaps, or
  happens to contain a /*.  /* is rare and easily fixed, but not string
  gaps.
 
  It looks like a workaround would be to manually inspect the files for
  LANGUAGE CPP and run two haddock passes, but then I would have to get
  the two passes to cooperate creating a single TOC and index.
 
  Isn't there some way to run haddock on files that use CPP?
 
  In the broader scheme, it seems perverse to be using CPP in the first
  place.  I use it to configure imports and exports, e.g. to swap out a
  driver backend on different OSes, and to export more symbols when
  testing.  Would it make sense to have a haskell version of CPP that
  provides only these features (e.g. just #ifdef, #else, #endif, and
  #define) and leaves out the problematic C comments and backslash
  expectations?
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe



 --
 Felipe.

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


Re: [Haskell-cafe] getting haddock to cooperate with cpp

2013-07-12 Thread Felipe Almeida Lessa
I guess that cabal preprocesses the files before calling Haddock then.
 Perhaps that's why it asks me to `cabal configure` before `cabal
haddock`ing =).  If you're able to switch over to cabal, that may be
the easiest solution.

Cheers,

On Fri, Jul 12, 2013 at 6:31 PM, Evan Laforge qdun...@gmail.com wrote:
 I'm calling haddock myself. Cabal might have some special magic for CPP,
 when I searched for haddock CPP I got some old bugs about adding cabal
 support. So presumably it's possible.

 On Jul 12, 2013 1:15 PM, Felipe Almeida Lessa felipe.le...@gmail.com
 wrote:

 Are you using `cabal haddock` or calling haddock manually?

 Cheers,

 On Fri, Jul 12, 2013 at 3:25 PM, Evan Laforge qdun...@gmail.com wrote:
  So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any
  file that uses it.  But if you pass --optghc=-cpp, it runs CPP on
  everything, which makes it crash on any file that uses string gaps, or
  happens to contain a /*.  /* is rare and easily fixed, but not string
  gaps.
 
  It looks like a workaround would be to manually inspect the files for
  LANGUAGE CPP and run two haddock passes, but then I would have to get
  the two passes to cooperate creating a single TOC and index.
 
  Isn't there some way to run haddock on files that use CPP?
 
  In the broader scheme, it seems perverse to be using CPP in the first
  place.  I use it to configure imports and exports, e.g. to swap out a
  driver backend on different OSes, and to export more symbols when
  testing.  Would it make sense to have a haskell version of CPP that
  provides only these features (e.g. just #ifdef, #else, #endif, and
  #define) and leaves out the problematic C comments and backslash
  expectations?
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe



 --
 Felipe.



-- 
Felipe.

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