Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Arnaud Bailly
Anyway, I will reinstall Haskell platform and read carefully your post to be
sure I do not screwed my setup again in the future.

Best regards,
Arnaud

On Mon, Aug 29, 2011 at 8:41 AM, Arnaud Bailly wrote:

> Thanks again for your patience and efforts. I am pretty sure I did not
> remove anything from the global package scope, at least intentionally. But
> of course I may have done things whcih you did not recommend. Here is the
> command-line history:
>
> ghc-pgk unregister --user template-haskell
>
> ghc-pkg unregister --user template-haskell
> ghc-pkg unregister --force --user template-haskell
> ghc-pkg unregister --force --user quickcheck
> ghc-pkg unregister --force --user QuickCheck
> ghc-pkg unregister --force --user template-haskell
> cd C:\Documents and Settings\abailly\Application
> Data\ghc\i386-mingw32-7.0.3\
> dir
> c:
> dir
> cd package.conf.d
> dir
> cd ..
> rm -fr package.conf.d
> d:
> ghc-pkg check
> ghc-pkg update
> ghc-pkg recache
>
> Regards,
> Arnaud
>
>
> On Mon, Aug 29, 2011 at 4:03 AM, Albert Y. C. Lai  wrote:
>
>> On 11-08-28 04:40 PM, Arnaud Bailly wrote:
>>
>>> Hello Albert,
>>> Thanks for taking the time to help me fix this package stuff. So I wiped
>>> out my package.conf.d/ and tried to reinstall my stuff. Installing
>>> template-haskell 2.5.0.0 is ok (2.6 is not, fails to compile on ghc
>>> 7.0.3) but then:
>>>
>>> D:\projets\>ghc --make -package ghc main
>>> : cannot satisfy -package ghc
>>> (use -v for more information)
>>>
>>> I suspect I really *do* have to reinstall haskell-platform. Here is the
>>> output of ghc-pkg list -v:
>>>
>>> using cache: C:\Documents and Settings\abailly\Application
>>> Data\ghc\i386-mingw32-7.0.3\**package.conf.d\package.cache
>>> using cache: D:/Program Files/Haskell
>>> Platform/2011.2.0.1\lib\**package.conf.d\package.cache
>>> D:/Program Files/Haskell Platform/2011.2.0.1\lib\**package.conf.d:
>>> Cabal-1.10.1.0 (Cabal-1.10.1.0-**55f781465ee9f32289755ad706c71f**0f)
>>> GLUT-2.1.2.1 (GLUT-2.1.2.1-**2d30997b9a19d27be388572e75af52**bf)
>>> HTTP-4000.1.1 (HTTP-4000.1.1-**267a332938fa742ba5a5d59de0b46d**60)
>>> HUnit-1.2.2.3 (HUnit-1.2.2.3-**102fbfbd594cd6d38461f5c68d8809**96)
>>> OpenGL-2.2.3.0 (OpenGL-2.2.3.0-**a58ce3ad6070e6b7932a3e779be57f**75)
>>> Win32-2.2.0.1 (Win32-2.2.0.1-**26cf39fdf591bdac61b11d5a443c62**ab)
>>> array-0.3.0.2 (array-0.3.0.2-**8e9cd0144e87fa9cc86cc9031631c4**f3)
>>> base-4.3.1.0 (base-4.3.1.0-**f520cd232cc386346843c4a12b63f4**4b)
>>> bin-package-db-0.0.0.0
>>> (bin-package-db-0.0.0.0-**97d865e5935b41538bcb29fc1040ae**7d)
>>> bytestring-0.9.1.10
>>> (bytestring-0.9.1.10-**cd85f14e02463c02ba4c77d7adcdb5**4f)
>>> cgi-3001.1.7.4 (cgi-3001.1.7.4-**659440ce11c2975fd9c9c471a1e8ff**3b)
>>> containers-0.4.0.0
>>> (containers-0.4.0.0-**18deac99a132f04751d862b77aab13**6e)
>>> deepseq-1.1.0.2 (deepseq-1.1.0.2-**09b3aed0c4982bbc6569c668100876**
>>> fa)
>>> directory-1.1.0.0 (directory-1.1.0.0-**
>>> 3a2367d72569467a8af8a231656ff1**b8)
>>> extensible-exceptions-0.1.1.2
>>> (extensible-exceptions-0.1.1.**2-**d8c5b906654260efd7249f497d17a8**31)
>>> ffi-1.0 (builtin_ffi)
>>> fgl-5.4.2.3 (fgl-5.4.2.3-**595811d6eabb1e1768685703ea66e9**82)
>>> filepath-1.2.0.0 (filepath-1.2.0.0-**f132e9f7703da4e20a47ff2b9acf1e*
>>> *a1)
>>> (ghc-binary-0.5.0.2
>>> (ghc-binary-0.5.0.2-**aba2b5dca5546ea1a972188de48f87**b5))
>>> ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-**e1f7c380581d61d42b0360d440cc35*
>>> *ed)
>>> haskell-src-1.0.1.4
>>> (haskell-src-1.0.1.4-**7428a8c9049cd6bf5abdc0bbd2d417**c5)
>>> (haskell2010-1.0.0.0
>>> (haskell2010-1.0.0.0-**53d9cd65595c551eea0c0269f534b5**e0))
>>> haskell98-1.1.0.1 (haskell98-1.1.0.1-**
>>> 35ec26bae828637c1638c8be441b3d**68)
>>> hpc-0.5.0.6 (hpc-0.5.0.6-**481dbb43fb624c21ad3bb9434675e3**ac)
>>> html-1.0.1.2 (html-1.0.1.2-**a494249f98a0f38b1a8db28bc70f8b**0b)
>>> integer-gmp-0.2.0.3
>>> (integer-gmp-0.2.0.3-**91607778cf3ae8f3948a50062b4f84**79)
>>> mtl-2.0.1.0 (mtl-2.0.1.0-**fb4d1695269b74308c1517c06b76e6**e8)
>>> network-2.3.0.2 (network-2.3.0.2-**47657e39a6118a978d9f443d72e85d**
>>> 4a)
>>> old-locale-1.0.0.2
>>> (old-locale-1.0.0.2-**6e2a3c0744e8cf4e0ac2d4e58659f7**b5)
>>> old-time-1.0.0.6 (old-time-1.0.0.6-**445ce39cbcebd38069c25c0f383b72*
>>> *8d)
>>> parallel-3.1.0.1 (parallel-3.1.0.1-**6eaa564e1ef1537bc88ad1fea6c90f*
>>> *e2)
>>> parsec-3.1.1 (parsec-3.1.1-**9da59b00c02e52f9f62f3c87c7e0e2**ec)
>>> pretty-1.0.1.2 (pretty-1.0.1.2-**abc7c632374e50e1c1927987c2651f**0f)
>>> process-1.0.1.5 (process-1.0.1.5-**b3dded8e54a2e13d22af410bdcfaff**
>>> f4)
>>> random-1.0.0.3 (random-1.0.0.3-**1abde37180be5476311abeefe300ab**c2)
>>> regex-base-0.93.2 (regex-base-0.93.2-**
>>> 9e1b027c41dbec856469a30982495b**b9)
>>> regex-compat-0.93.1
>>> (regex-compat-0.93.1-**31c61fe0aee45e8a9853edf7a844f7**4e)
>>> regex-posix-0.94.4
>>> (regex-posix-0.94.4-**f5eb628ea5dae5f91552d5ea0e2635**9d)

Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Arnaud Bailly
Thanks again for your patience and efforts. I am pretty sure I did not
remove anything from the global package scope, at least intentionally. But
of course I may have done things whcih you did not recommend. Here is the
command-line history:

ghc-pgk unregister --user template-haskell
ghc-pkg unregister --user template-haskell
ghc-pkg unregister --force --user template-haskell
ghc-pkg unregister --force --user quickcheck
ghc-pkg unregister --force --user QuickCheck
ghc-pkg unregister --force --user template-haskell
cd C:\Documents and Settings\abailly\Application
Data\ghc\i386-mingw32-7.0.3\
dir
c:
dir
cd package.conf.d
dir
cd ..
rm -fr package.conf.d
d:
ghc-pkg check
ghc-pkg update
ghc-pkg recache

Regards,
Arnaud

On Mon, Aug 29, 2011 at 4:03 AM, Albert Y. C. Lai  wrote:

> On 11-08-28 04:40 PM, Arnaud Bailly wrote:
>
>> Hello Albert,
>> Thanks for taking the time to help me fix this package stuff. So I wiped
>> out my package.conf.d/ and tried to reinstall my stuff. Installing
>> template-haskell 2.5.0.0 is ok (2.6 is not, fails to compile on ghc
>> 7.0.3) but then:
>>
>> D:\projets\>ghc --make -package ghc main
>> : cannot satisfy -package ghc
>> (use -v for more information)
>>
>> I suspect I really *do* have to reinstall haskell-platform. Here is the
>> output of ghc-pkg list -v:
>>
>> using cache: C:\Documents and Settings\abailly\Application
>> Data\ghc\i386-mingw32-7.0.3\**package.conf.d\package.cache
>> using cache: D:/Program Files/Haskell
>> Platform/2011.2.0.1\lib\**package.conf.d\package.cache
>> D:/Program Files/Haskell Platform/2011.2.0.1\lib\**package.conf.d:
>> Cabal-1.10.1.0 (Cabal-1.10.1.0-**55f781465ee9f32289755ad706c71f**0f)
>> GLUT-2.1.2.1 (GLUT-2.1.2.1-**2d30997b9a19d27be388572e75af52**bf)
>> HTTP-4000.1.1 (HTTP-4000.1.1-**267a332938fa742ba5a5d59de0b46d**60)
>> HUnit-1.2.2.3 (HUnit-1.2.2.3-**102fbfbd594cd6d38461f5c68d8809**96)
>> OpenGL-2.2.3.0 (OpenGL-2.2.3.0-**a58ce3ad6070e6b7932a3e779be57f**75)
>> Win32-2.2.0.1 (Win32-2.2.0.1-**26cf39fdf591bdac61b11d5a443c62**ab)
>> array-0.3.0.2 (array-0.3.0.2-**8e9cd0144e87fa9cc86cc9031631c4**f3)
>> base-4.3.1.0 (base-4.3.1.0-**f520cd232cc386346843c4a12b63f4**4b)
>> bin-package-db-0.0.0.0
>> (bin-package-db-0.0.0.0-**97d865e5935b41538bcb29fc1040ae**7d)
>> bytestring-0.9.1.10
>> (bytestring-0.9.1.10-**cd85f14e02463c02ba4c77d7adcdb5**4f)
>> cgi-3001.1.7.4 (cgi-3001.1.7.4-**659440ce11c2975fd9c9c471a1e8ff**3b)
>> containers-0.4.0.0
>> (containers-0.4.0.0-**18deac99a132f04751d862b77aab13**6e)
>> deepseq-1.1.0.2 (deepseq-1.1.0.2-**09b3aed0c4982bbc6569c668100876**
>> fa)
>> directory-1.1.0.0 (directory-1.1.0.0-**3a2367d72569467a8af8a231656ff1
>> **b8)
>> extensible-exceptions-0.1.1.2
>> (extensible-exceptions-0.1.1.**2-**d8c5b906654260efd7249f497d17a8**31)
>> ffi-1.0 (builtin_ffi)
>> fgl-5.4.2.3 (fgl-5.4.2.3-**595811d6eabb1e1768685703ea66e9**82)
>> filepath-1.2.0.0 (filepath-1.2.0.0-**f132e9f7703da4e20a47ff2b9acf1e**
>> a1)
>> (ghc-binary-0.5.0.2
>> (ghc-binary-0.5.0.2-**aba2b5dca5546ea1a972188de48f87**b5))
>> ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-**e1f7c380581d61d42b0360d440cc35**
>> ed)
>> haskell-src-1.0.1.4
>> (haskell-src-1.0.1.4-**7428a8c9049cd6bf5abdc0bbd2d417**c5)
>> (haskell2010-1.0.0.0
>> (haskell2010-1.0.0.0-**53d9cd65595c551eea0c0269f534b5**e0))
>> haskell98-1.1.0.1 (haskell98-1.1.0.1-**35ec26bae828637c1638c8be441b3d
>> **68)
>> hpc-0.5.0.6 (hpc-0.5.0.6-**481dbb43fb624c21ad3bb9434675e3**ac)
>> html-1.0.1.2 (html-1.0.1.2-**a494249f98a0f38b1a8db28bc70f8b**0b)
>> integer-gmp-0.2.0.3
>> (integer-gmp-0.2.0.3-**91607778cf3ae8f3948a50062b4f84**79)
>> mtl-2.0.1.0 (mtl-2.0.1.0-**fb4d1695269b74308c1517c06b76e6**e8)
>> network-2.3.0.2 (network-2.3.0.2-**47657e39a6118a978d9f443d72e85d**
>> 4a)
>> old-locale-1.0.0.2
>> (old-locale-1.0.0.2-**6e2a3c0744e8cf4e0ac2d4e58659f7**b5)
>> old-time-1.0.0.6 (old-time-1.0.0.6-**445ce39cbcebd38069c25c0f383b72**
>> 8d)
>> parallel-3.1.0.1 (parallel-3.1.0.1-**6eaa564e1ef1537bc88ad1fea6c90f**
>> e2)
>> parsec-3.1.1 (parsec-3.1.1-**9da59b00c02e52f9f62f3c87c7e0e2**ec)
>> pretty-1.0.1.2 (pretty-1.0.1.2-**abc7c632374e50e1c1927987c2651f**0f)
>> process-1.0.1.5 (process-1.0.1.5-**b3dded8e54a2e13d22af410bdcfaff**
>> f4)
>> random-1.0.0.3 (random-1.0.0.3-**1abde37180be5476311abeefe300ab**c2)
>> regex-base-0.93.2 (regex-base-0.93.2-**9e1b027c41dbec856469a30982495b
>> **b9)
>> regex-compat-0.93.1
>> (regex-compat-0.93.1-**31c61fe0aee45e8a9853edf7a844f7**4e)
>> regex-posix-0.94.4
>> (regex-posix-0.94.4-**f5eb628ea5dae5f91552d5ea0e2635**9d)
>> rts-1.0 (builtin_rts)
>> stm-2.2.0.1 (stm-2.2.0.1-**57e291244ee02349552a4f79caeb4f**fe)
>> syb-0.3 (syb-0.3-**8db7bc4339a1cb8a6f2a46c40447ef**0b)
>> text-0.11.0.6 (text-0.11.0.6-**398a3f02891247aea46662fc7379c4**a5)
>> time-1.2.0.3 (time-1.2.0.3-**74ef6ac31cee9aec02b036978af002**d2)
>> transformers-0.2.2.0
>> (transfo

Re: [Haskell-cafe] hledger subcommand detection, RFC

2011-08-28 Thread Conrad Parker
On 27 August 2011 00:23, Simon Michael  wrote:
> Thanks Conrad! Those are some great links.
>
>> I wrapped up some manpage generation code in a package called
>> ui-command, which is kind of orthogonal to cmdargs (ui-command just
>> deals with subcommands). Example commands are often useful, so I added
>
> Interesting. Have you tried using both ui-command and cmdargs together ?

No, I've generally just used ui-command to select (and document)
subcommands, and GetOpt to handle arguments. I think cmdargs added
support for selecting subcommands recently.

In any case, you are selecting subcommands by searching the
filesystem. Perhaps it would be a good idea to split out the
documentation part of ui-command ...

Conrad.

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


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Sebastian Fischer
On Mon, Aug 29, 2011 at 12:24 PM, Maciej Marcin Piechotka
 wrote:

> instance Functor FList where
>    f `fmap` FList g = ...?

Yes, Functor is also one of the classes that can only be implemented
by converting to ordinary lists (I think).

So FList could only be made an instance of Pointed without (certain)
superclass constraints.

Sebastian

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


Re: [Haskell-cafe] Bug in GC's ordering of ForeignPtr finalization?

2011-08-28 Thread Antoine Latter
On Sun, Aug 28, 2011 at 10:47 PM, Ben Gamari  wrote:
> On Sun, 28 Aug 2011 22:26:05 -0500, Antoine Latter  wrote:
>> One problem you might be running in to is that the optimization passes
>> can notice that a function isn't using all of its arguments, and then
>> it won't pass them. These even applies if the arguments are bound
>> together in a record type.
>>
> In this case I wouldn't be able to reproduce the problem with
> optimization disabled, no? Unfortunately, this is not the case; the
> problem persists even with -O0.
>

Perhaps? I don't know the details about how the GC decides when
something is reachable. The scenario I described (which sounds similar
to yours?) is only safe in Haskell when using functions like
touchForeignPtr.

Antoine

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


Re: [Haskell-cafe] Bug in GC's ordering of ForeignPtr finalization?

2011-08-28 Thread Ben Gamari
On Sun, 28 Aug 2011 22:26:05 -0500, Antoine Latter  wrote:
> One problem you might be running in to is that the optimization passes
> can notice that a function isn't using all of its arguments, and then
> it won't pass them. These even applies if the arguments are bound
> together in a record type.
> 
In this case I wouldn't be able to reproduce the problem with
optimization disabled, no? Unfortunately, this is not the case; the
problem persists even with -O0.

- Ben

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


Re: [Haskell-cafe] only anecdotal .... not a proof of a trend ...

2011-08-28 Thread Vasili I. Galchin
My bad  I misread the QNX part. I thought they wanted to use QNX. Sorry.
At one company I did a contract at, they use pSOS with a large code base ...
so you are correct .. they won't change to QNX even though there is no new
development in pSOS.

Vasili

On Sun, Aug 28, 2011 at 10:04 PM, Brandon Allbery wrote:

> On Sun, Aug 28, 2011 at 22:33, Vasili I. Galchin wrote:
>
>>  1) The reason I said "over the top" is that QNX is highly optimized
>> to bound kernel pathways. I was able to read kernel code. I have also worked
>> on LynxOS and pSOS. Not dissing you [?]
>>
>
> Sure, there are plenty of RTOSes out there.  There were back then, too;
> there are still times when simpler environments are preferred (admittedly,
> some of them are more psychological than justifiable by the intended usage).
>  I still think "over the top" is itself a bit over the top; we are far from
> being able to replace the immense number of traditional PLCs or embedded
> devices out there which nevertheless need to be retrofitted in software to
> support newer technologies.  (See below; you have about 0% chance of getting
> someone to rip out all the existing PLCs on every segment of every track in
> the country and replace it with a computer running QNX or VXWorks.  Even
> ignoring the [mostly labor, but with the number of devices in question even
> the hardware adds up] cost, consider the logistics; the segments that need
> it most are the ones you can't afford to take offline for any significant
> amount of time while refitting and testing the new gear.)
>
> Now imagine that someone has a large deployed base of simple dedicated
> embedded hardware and needs to retrofit SMTP into it.  That's a
> software-only change, and waving a manual while intoning "QNX" won't get you
> anywhere with the hardware.
>
>
>>  2) What is the Haskell package that you are alluding to. I would like
>> to know plus probably others on this list.
>>
>
> Hm, I'm not sure it hit Hackage; I'm not seeing anything obvious there
> aside from vaguely recalling some changes to Atom to make it more suitable
> for code generation for PLCs.  You might, however, take a look at
> http://cs.swan.ac.uk/~cspj/docs/calco.pdf which uses Haskell SAT solvers
> to validate PLC ladder logic for track safety; I don't know how much of the
> rest of the system is in Haskell.
>
> --
> brandon s allbery  allber...@gmail.com
> wandering unix systems administrator (available) (412) 475-9364 vm/sms
>
>
<<330.gif>>___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Bug in GC's ordering of ForeignPtr finalization?

2011-08-28 Thread Antoine Latter
On Sun, Aug 28, 2011 at 4:27 PM, Ben Gamari  wrote:
> On Tue, 16 Aug 2011 12:32:13 -0400, Ben Gamari  wrote:
>> It seems that the notmuch-haskell bindings (version 0.2.2 built against
>> notmuch from git master; passes notmuch-test) aren't dealing with memory
>> management properly. In particular, the attached test code[1] causes
>> talloc to abort.  Unfortunately, while the issue is consistently
>> reproducible, it only occurs with some queries (see source[1]). I have
>> been unable to establish the exact criterion for failure.
>>
>> It seems that the crash is caused by an invalid access to a freed Query
>> object while freeing a Messages object (see Valgrind trace[3]). I've
>> taken a brief look at the bindings themselves but, being only minimally
>> familiar with the FFI, there's nothing obviously wrong (the finalizers
>> passed to newForeignPtr look sane). I was under the impression that
>> talloc was reference counted, so the Query object shouldn't have been
>> freed unless if there was still a Messages object holding a
>> reference. Any idea what might have gone wrong here?  Thanks!
>>
> After looking into this issue in a bit more depth, I'm even more
> confused. In fact, I would not be surprised if I have stumbled into a
> bug in the GC. It seems that the notmuch-haskell bindings follow the
> example of the python bindings in that child objects keep references to
> their parents to prevent the garbage collector from releasing the
> parent, which would in turn cause talloc to free the child objects,
> resulting in odd behavior when the child objects were next accessed. For
> instance, the Query and Messages objects are defined as follows,
>
>    type MessagesPtr = ForeignPtr S__notmuch_messages
>    type MessagePtr = ForeignPtr S__notmuch_message
>    newtype Query = Query (ForeignPtr S__notmuch_query)
>    data MessagesRef = QueryMessages { qmpp :: Query, msp :: MessagesPtr }
>                     | ThreadMessages { tmpp :: Thread, msp :: MessagesPtr }
>                     | MessageMessages { mmspp :: Message, msp :: MessagesPtr }
>    data Message = MessagesMessage { msmpp :: MessagesRef, mp :: MessagePtr }
>                 | Message { mp :: MessagePtr }
>    type Messages = [Message]
>

One problem you might be running in to is that the optimization passes
can notice that a function isn't using all of its arguments, and then
it won't pass them. These even applies if the arguments are bound
together in a record type.

So if you have a record type:

> data QueryResult = QR {qrQueryPtr :: ForeignPtr (), qrResultPointer :: Ptr ()}

and a function:

> processQueryResult :: QueryResult -> IO (...)

If the function doesn't use the 'qrQueryPointer' part of the record,
the compiler may not even pass it in. This might run the finalizer for
the foreign pointer earlier than you expect. If the result pointer is
a part of the query foreign pointer, you're in trouble.

I'm not sure if this is what's happening, but it sounds like it could be.

If this is the case you might want to build some helper functions
using the function 'touchForeignPtr', which does nothing other than
make it look like the foreign pointer is still in use. In my example
it might be something like:

> withQueryResultPtr :: QueryResult -> (Ptr QueryResult -> IO a) -> IO a
> withQueryResultPtr qr k = do
>x <- k (qrQueryPtr qr)
>touchForeignPtr (qrResultPointer qr)
>return x

Antoine

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


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Maciej Marcin Piechotka
On Mon, 2011-08-29 at 12:00 +0900, Sebastian Fischer wrote:
> On Sun, Aug 28, 2011 at 12:41 AM, Sönke Hahn  wrote:
> > I was wondering which
> > type could be an instance of Pointed, but not of Applicative. But I can't
> > think of one. Any ideas?
> 
> Functional lists:
> 
> type FList a = [a] -> [a]
> 
> they have a Monoid instance for empty and append, a "point" function
> for singletons but Applicative or Monad cannot be defined without
> converting back and forth to ordinary lists.
> 
> Sebastian

newtype FList a = FList ([a] -> [a])

instance Functor FList where
f `fmap` FList g = ...?

The only possible implementation I can think of:

f `fmap` FList g = _|_
f `fmap` FList g = map id
f `fmap` FList g = map _|_
(+ variation of _|_*)

Neither of them holding fmap id = id.

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] only anecdotal .... not a proof of a trend ...

2011-08-28 Thread Brandon Allbery
On Sun, Aug 28, 2011 at 22:33, Vasili I. Galchin wrote:

>  1) The reason I said "over the top" is that QNX is highly optimized to
> bound kernel pathways. I was able to read kernel code. I have also worked on
> LynxOS and pSOS. Not dissing you [?]
>

Sure, there are plenty of RTOSes out there.  There were back then, too;
there are still times when simpler environments are preferred (admittedly,
some of them are more psychological than justifiable by the intended usage).
 I still think "over the top" is itself a bit over the top; we are far from
being able to replace the immense number of traditional PLCs or embedded
devices out there which nevertheless need to be retrofitted in software to
support newer technologies.  (See below; you have about 0% chance of getting
someone to rip out all the existing PLCs on every segment of every track in
the country and replace it with a computer running QNX or VXWorks.  Even
ignoring the [mostly labor, but with the number of devices in question even
the hardware adds up] cost, consider the logistics; the segments that need
it most are the ones you can't afford to take offline for any significant
amount of time while refitting and testing the new gear.)

Now imagine that someone has a large deployed base of simple dedicated
embedded hardware and needs to retrofit SMTP into it.  That's a
software-only change, and waving a manual while intoning "QNX" won't get you
anywhere with the hardware.


>  2) What is the Haskell package that you are alluding to. I would like
> to know plus probably others on this list.
>

Hm, I'm not sure it hit Hackage; I'm not seeing anything obvious there aside
from vaguely recalling some changes to Atom to make it more suitable for
code generation for PLCs.  You might, however, take a look at
http://cs.swan.ac.uk/~cspj/docs/calco.pdf which uses Haskell SAT solvers to
validate PLC ladder logic for track safety; I don't know how much of the
rest of the system is in Haskell.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
<<330.gif>>___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Sebastian Fischer
On Sun, Aug 28, 2011 at 12:41 AM, Sönke Hahn  wrote:
> I was wondering which
> type could be an instance of Pointed, but not of Applicative. But I can't
> think of one. Any ideas?

Functional lists:

type FList a = [a] -> [a]

they have a Monoid instance for empty and append, a "point" function
for singletons but Applicative or Monad cannot be defined without
converting back and forth to ordinary lists.

Sebastian

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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Albert Y. C. Lai

On 11-08-28 10:38 PM, Brandon Allbery wrote:

On Sun, Aug 28, 2011 at 22:13, Albert Y. C. Lai mailto:tre...@vex.net>> wrote:

On 11-08-28 04:53 PM, Brandon Allbery wrote:

That'd be expected; you shouldn't simply obliterate
package.conf.d, you
need to keep ghc's boot libraries (which include itself as a
library).
  If the boot libraries are somehow hosed, you need to reinstall the
compiler to get them back.


Different package.conf.d


Except that, as you discovered later, the user was obviously talking
about having obliterated the system one.  :(


Explain to me why the following survives obliteration:

D:/Program Files/Haskell Platform/2011.2.0.1\lib\package.conf.d:
[...]
base-4.3.1.0 (base-4.3.1.0-f520cd232cc386346843c4a12b63f44b)
bin-package-db-0.0.0.0 
(bin-package-db-0.0.0.0-97d865e5935b41538bcb29fc1040ae7d)

[...]
ffi-1.0 (builtin_ffi)
(ghc-binary-0.5.0.2 
(ghc-binary-0.5.0.2-aba2b5dca5546ea1a972188de48f87b5))

ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-e1f7c380581d61d42b0360d440cc35ed)
[...]
integer-gmp-0.2.0.3 
(integer-gmp-0.2.0.3-91607778cf3ae8f3948a50062b4f8479)

rts-1.0 (builtin_rts)
[...]

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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Brandon Allbery
On Sun, Aug 28, 2011 at 22:13, Albert Y. C. Lai  wrote:

> On 11-08-28 04:53 PM, Brandon Allbery wrote:
>
>> That'd be expected; you shouldn't simply obliterate package.conf.d, you
>> need to keep ghc's boot libraries (which include itself as a library).
>>  If the boot libraries are somehow hosed, you need to reinstall the
>> compiler to get them back.
>>
>
> Different package.conf.d
>

Except that, as you discovered later, the user was obviously talking about
having obliterated the system one.  :(

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] only anecdotal .... not a proof of a trend ...

2011-08-28 Thread Vasili I. Galchin
Hi Brandon,

 1) The reason I said "over the top" is that QNX is highly optimized to
bound kernel pathways. I was able to read kernel code. I have also worked on
LynxOS and pSOS. Not dissing you [?]

 2) What is the Haskell package that you are alluding to. I would like
to know plus probably others on this list.

Kind regards,

Vasili



On Sun, Aug 28, 2011 at 9:27 PM, Brandon Allbery wrote:

> On Sun, Aug 28, 2011 at 21:27, Vasili I. Galchin wrote:
>
>> From the context of #2, I can tell the author didn't mean all of the "?"'s
>> but instead maybe "!".
>>
>
> More likely — or • and they got remapped to ?s by incorrect encodings.
>
>
>> The OS QNX is a hard real-time OS that uses a message passing IPC. I have
>> worked QNX and have written a device driver for QNX.
>> (...)
>
> attending non-determinism. No "OS function calls" seems way over the top.
>>
>
> It's not over the top; it's traditional embedded device programming, where
> there isn't an OS available, just a simple BIOS (and I don't mean the MS-DOS
> one).  I suppose kids these days expect even embedded environments to be
> fairly high end CPUs with full memory management and full OSes... nope.
>  There's even still ladder logic out there — and at least one recent Haskell
> package aimed at programming for it.
>
> --
> brandon s allbery  allber...@gmail.com
> wandering unix systems administrator (available) (412) 475-9364 vm/sms
>
>
<<330.gif>>___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] only anecdotal .... not a proof of a trend ...

2011-08-28 Thread Brandon Allbery
On Sun, Aug 28, 2011 at 21:27, Vasili I. Galchin wrote:

> From the context of #2, I can tell the author didn't mean all of the "?"'s
> but instead maybe "!".
>

More likely — or • and they got remapped to ?s by incorrect encodings.


> The OS QNX is a hard real-time OS that uses a message passing IPC. I have
> worked QNX and have written a device driver for QNX.
> (...)

attending non-determinism. No "OS function calls" seems way over the top.
>

It's not over the top; it's traditional embedded device programming, where
there isn't an OS available, just a simple BIOS (and I don't mean the MS-DOS
one).  I suppose kids these days expect even embedded environments to be
fairly high end CPUs with full memory management and full OSes... nope.
 There's even still ladder logic out there — and at least one recent Haskell
package aimed at programming for it.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Albert Y. C. Lai

On 11-08-28 04:53 PM, Brandon Allbery wrote:

That'd be expected; you shouldn't simply obliterate package.conf.d, you
need to keep ghc's boot libraries (which include itself as a library).
  If the boot libraries are somehow hosed, you need to reinstall the
compiler to get them back.


Different package.conf.d

I suggested obliterating C:\Documents and Settings\abailly\Application 
Data\ghc\i386-mingw32-7.0.3\package.conf.d (on linux it would be called 
~/.ghc/i386-linux-7.0.3/package.conf.d). That would just drop user 
packages and not touch boot packages (global packages for that matter).


You can also see that under the listing of D:/Program Files/Haskell 
Platform/2011.2.0.1\lib\package.conf.d the majority of packages are 
still there, not obliterated. (For example base, bin-package-db are 
still there.)


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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Albert Y. C. Lai

On 11-08-28 04:40 PM, Arnaud Bailly wrote:

Hello Albert,
Thanks for taking the time to help me fix this package stuff. So I wiped
out my package.conf.d/ and tried to reinstall my stuff. Installing
template-haskell 2.5.0.0 is ok (2.6 is not, fails to compile on ghc
7.0.3) but then:

D:\projets\>ghc --make -package ghc main
: cannot satisfy -package ghc
 (use -v for more information)

I suspect I really *do* have to reinstall haskell-platform. Here is the
output of ghc-pkg list -v:

using cache: C:\Documents and Settings\abailly\Application
Data\ghc\i386-mingw32-7.0.3\package.conf.d\package.cache
using cache: D:/Program Files/Haskell
Platform/2011.2.0.1\lib\package.conf.d\package.cache
D:/Program Files/Haskell Platform/2011.2.0.1\lib\package.conf.d:
 Cabal-1.10.1.0 (Cabal-1.10.1.0-55f781465ee9f32289755ad706c71f0f)
 GLUT-2.1.2.1 (GLUT-2.1.2.1-2d30997b9a19d27be388572e75af52bf)
 HTTP-4000.1.1 (HTTP-4000.1.1-267a332938fa742ba5a5d59de0b46d60)
 HUnit-1.2.2.3 (HUnit-1.2.2.3-102fbfbd594cd6d38461f5c68d880996)
 OpenGL-2.2.3.0 (OpenGL-2.2.3.0-a58ce3ad6070e6b7932a3e779be57f75)
 Win32-2.2.0.1 (Win32-2.2.0.1-26cf39fdf591bdac61b11d5a443c62ab)
 array-0.3.0.2 (array-0.3.0.2-8e9cd0144e87fa9cc86cc9031631c4f3)
 base-4.3.1.0 (base-4.3.1.0-f520cd232cc386346843c4a12b63f44b)
 bin-package-db-0.0.0.0
(bin-package-db-0.0.0.0-97d865e5935b41538bcb29fc1040ae7d)
 bytestring-0.9.1.10
(bytestring-0.9.1.10-cd85f14e02463c02ba4c77d7adcdb54f)
 cgi-3001.1.7.4 (cgi-3001.1.7.4-659440ce11c2975fd9c9c471a1e8ff3b)
 containers-0.4.0.0
(containers-0.4.0.0-18deac99a132f04751d862b77aab136e)
 deepseq-1.1.0.2 (deepseq-1.1.0.2-09b3aed0c4982bbc6569c668100876fa)
 directory-1.1.0.0 (directory-1.1.0.0-3a2367d72569467a8af8a231656ff1b8)
 extensible-exceptions-0.1.1.2
(extensible-exceptions-0.1.1.2-d8c5b906654260efd7249f497d17a831)
 ffi-1.0 (builtin_ffi)
 fgl-5.4.2.3 (fgl-5.4.2.3-595811d6eabb1e1768685703ea66e982)
 filepath-1.2.0.0 (filepath-1.2.0.0-f132e9f7703da4e20a47ff2b9acf1ea1)
 (ghc-binary-0.5.0.2
(ghc-binary-0.5.0.2-aba2b5dca5546ea1a972188de48f87b5))
 ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-e1f7c380581d61d42b0360d440cc35ed)
 haskell-src-1.0.1.4
(haskell-src-1.0.1.4-7428a8c9049cd6bf5abdc0bbd2d417c5)
 (haskell2010-1.0.0.0
(haskell2010-1.0.0.0-53d9cd65595c551eea0c0269f534b5e0))
 haskell98-1.1.0.1 (haskell98-1.1.0.1-35ec26bae828637c1638c8be441b3d68)
 hpc-0.5.0.6 (hpc-0.5.0.6-481dbb43fb624c21ad3bb9434675e3ac)
 html-1.0.1.2 (html-1.0.1.2-a494249f98a0f38b1a8db28bc70f8b0b)
 integer-gmp-0.2.0.3
(integer-gmp-0.2.0.3-91607778cf3ae8f3948a50062b4f8479)
 mtl-2.0.1.0 (mtl-2.0.1.0-fb4d1695269b74308c1517c06b76e6e8)
 network-2.3.0.2 (network-2.3.0.2-47657e39a6118a978d9f443d72e85d4a)
 old-locale-1.0.0.2
(old-locale-1.0.0.2-6e2a3c0744e8cf4e0ac2d4e58659f7b5)
 old-time-1.0.0.6 (old-time-1.0.0.6-445ce39cbcebd38069c25c0f383b728d)
 parallel-3.1.0.1 (parallel-3.1.0.1-6eaa564e1ef1537bc88ad1fea6c90fe2)
 parsec-3.1.1 (parsec-3.1.1-9da59b00c02e52f9f62f3c87c7e0e2ec)
 pretty-1.0.1.2 (pretty-1.0.1.2-abc7c632374e50e1c1927987c2651f0f)
 process-1.0.1.5 (process-1.0.1.5-b3dded8e54a2e13d22af410bdcfafff4)
 random-1.0.0.3 (random-1.0.0.3-1abde37180be5476311abeefe300abc2)
 regex-base-0.93.2 (regex-base-0.93.2-9e1b027c41dbec856469a30982495bb9)
 regex-compat-0.93.1
(regex-compat-0.93.1-31c61fe0aee45e8a9853edf7a844f74e)
 regex-posix-0.94.4
(regex-posix-0.94.4-f5eb628ea5dae5f91552d5ea0e26359d)
 rts-1.0 (builtin_rts)
 stm-2.2.0.1 (stm-2.2.0.1-57e291244ee02349552a4f79caeb4ffe)
 syb-0.3 (syb-0.3-8db7bc4339a1cb8a6f2a46c40447ef0b)
 text-0.11.0.6 (text-0.11.0.6-398a3f02891247aea46662fc7379c4a5)
 time-1.2.0.3 (time-1.2.0.3-74ef6ac31cee9aec02b036978af002d2)
 transformers-0.2.2.0
(transformers-0.2.2.0-2fe7b735c63a6cbe8724038d8e4d812a)
 xhtml-3000.2.0.1 (xhtml-3000.2.0.1-ace31b2e48c396e565655b0f34f5d2b7)
 zlib-0.5.3.1 (zlib-0.5.3.1-5fbdf714525b76e0e601c2ffb25f2044)

C:\Documents and Settings\abailly\Application
Data\ghc\i386-mingw32-7.0.3\package.conf.d:
 QuickCheck-2.4.1.1
(QuickCheck-2.4.1.1-04d68679694a517ba23022a4c6bc1cde)
 ghc-paths-0.1.0.8 (ghc-paths-0.1.0.8-be391faf057d651dbb92b73671fe9eee)
 template-haskell-2.5.0.0
(template-haskell-2.5.0.0-87f4f416a22a910e480ac9f269479a5f)
 utf8-string-0.3.7 (utf8-string-0.3.7-dcbcb8de655cdfe1c4c28c094f8c6799)

Thanks again,
Arnaud

On Sat, Aug 27, 2011 at 8:59 PM, Albert Y. C. Lai mailto:tre...@vex.net>> wrote:

You have too many instances of template-haskell. The important parts
are:


package ghc-7.0.3-__fc75cf67c86ba2c0d64b07024a18d3__b4 is unusable
due to missing or recursive dependencies:
  template-haskell-2.5.0.0-__7d9b1443ac5ab69e5ed705a487990d__eb

package
template-haskell-2.5.0.0-__7d9b1443ac5ab69e5ed705a487990d__eb is
shadowed by package
template-haskell-2.5.0.0-__87f4f416a22a910e480ac9f269479a__5f

and in "ghc-pkg list -v

[Haskell-cafe] only anecdotal .... not a proof of a trend ...

2011-08-28 Thread Vasili I. Galchin
Hello,

  I received two job postings ... my comments follows the postings:

--

*#1 Software Developer*

* *

Location: Austin, TX

Duration: 6 months

Rate : $60/hr -$70/hr on w2



*Required:*

*- Straight C experience - Generally need a pure C programmer to ideally
create 1 C file that can be compiled in Win32/Win64/Dos/Shell/Linux*

a.   Prefer C, not C++, but if only C++ still consider it.

b.  Past contractors tried to do too large of things like templates,
huge class structures, etc. so we prefer C over C++

c.   Upper level Windows programming such as .NET detracts because
client wants them to think about all targets, not just Windows

*- Linux experience – Generally need to get a Windows GUI application to be
re-compiled and run in Linux*

a. Hard to find, so first do a key word search of Linux
b. Programming applications background is a big plus
c. Looking for GUI experience so they can scope how the Win32 app looks then
implement the same experience in Linux
d. Client is lacking in Linux background, so need someone that needs minimal
help with Linux.



*Desired:*

- Application development – Have several Win32 applications that need to be
compiled as Win64 then tested

a. Experience in testing and familiar with looking for corner case scenarios

- Low level hardware/software interaction knowledge

a. Apps require running a SMI to initiate contact, need candidate to
understand difference between virtual and flat addressing


*#2 SMTP EMAIL SERVER - C*
Elance - United States
See original job posting at Elance
»
Developer to provide ANSI C software to send (receive not required) email
using an SMTP Server. This software must support: ? AUTH_LOGIN (base 64
encoding) ? NTLM ?

NTLM2 ? CRAM MD5 This software is targeted to run on an embedded
microcontroller but can be developed in Linux or Windows. The following
requirements MUST be met: ? No C++, No C++ Classes...etc ?

No .NET ? No DLLs ? No Libraries ? No OS dependencies (Windows/QNX/MQX or
any other OS) ?

No OS Function Calls ? 100% ANSI C Source is required. Desired Skills: C


--

Both seem to want to have nothing with C++ (dare I say OOPS?). I work in
mainstream industry. Have others on the mail list seen such job postings
recently?
 Is there now a trend against C++ due to somewhat loose type checking and
very statefullness? (Unlike Haskell which splits pure and monads very
clearly vis strong types).


#1
To C++ templates are much more bulky(and ugly) compared Haskell's
polymorphic types. However, it caused me to think where we Haskell
programmers can do "too large of things". ??? Perhaps an unfair question
given that I have no access to the current C++ code.




#2
>From the context of #2, I can tell the author didn't mean all of the "?"'s
but instead maybe "!".

The OS QNX is a hard real-time OS that uses a message passing IPC. I have
worked QNX and have written a device driver for QNX.
This job posting maybe very unfair argument against C++/OOPs as maybe the
thought is that C++ adds to much "non-determinism" to a hard real-time
problem. In the real-time extension to the POSIX API is a function "mlock"
which locks a process into memory(no swapping) which seriously helps to cut
down on non-determinism. Here Haskell would be worse with its garbage
collector with its attending non-determinism. No "OS function calls" seems
way over the top.


Sorry for my meandering thinking 


Regards,

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


Re: [Haskell-cafe] Unexpected Typeable behaviour; Prelude.undefined

2011-08-28 Thread Brandon Allbery
On Sun, Aug 28, 2011 at 18:44, Philip Holzenspies wrote:

> instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
>typeOf t@(MyADT _)
>

typeOf is usually invoked with an undefined parameter; it should use types,
never values.  Here you've defined it to deconstruct what it's passed, which
means that anything that uses it in the usual way (`typeOf (undefined ::
someType)') will immediately throw undefined.

You don't need a deconstructor there; you (correctly) throw away the value,
and it doesn't provide any type information not already available from the
instance declaration.  `typeOf t' should be good enough.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-28 Thread Daniel Fischer
On Monday 29 August 2011, 00:56:52, KC wrote:
> I just noticed that the 20x20 grid has some "00" entries; thus, time
> could be saved by not touching any of the grid entries 3 cells away.
> Same for the "01" entries.
> 
> The challenge, of course, is in finding these entries in the first
> place. :)

Multiplication is cheap, looking for zeros (or ones) would take much more 
time than the multiplications one could avoid, so it'd be a net loss (it 
could become a gain if longer sequences were to be considered; depends on 
the proportion of zeros in the grid and the length).

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


Re: [Haskell-cafe] Unexpected Typeable behaviour; Prelude.undefined

2011-08-28 Thread Ozgur Akgun
Hi Philip,

On 28 August 2011 23:44, Philip Holzenspies  wrote:
>
> import Data.Typeable
>
> data MyADT m = MyADT (m ())
>
> instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
>typeOf t@(MyADT _)
> = mkTyCon "MyADT"
>  `mkTyConApp`
>  [typeOf1 ((return :: Monad m => MyADT m -> m (MyADT m)) t)]
>

IIRC, typeOf is supposed to work with undefined as the argument.

Try: typeOf (undefined :: Int)

See:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Typeable.html#v:typeOf

I think the undefined is merely because the pattern matching you use in the
instance declaration fails.

Hope this helps,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-28 Thread KC
I just noticed that the 20x20 grid has some "00" entries; thus, time
could be saved by not touching any of the grid entries 3 cells away.
Same for the "01" entries.

The challenge, of course, is in finding these entries in the first place. :)


On Sun, Aug 28, 2011 at 1:58 PM, KC  wrote:
> Try something like the following:
>
> -- Project Euler 11
>
> -- In the 20×20 grid below, four numbers along a diagonal line have
> been marked in red.
>
> -- 
>
> -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.
>
> -- What is the greatest product of four adjacent numbers in any
> direction (up, down, left, right, or diagonally) in the 20×20 grid?
>
>
> import Data.List
>
> -- Doing the one dimensional case.
> f011 :: [Int] -> Int
> f011 (t:u:v:xs) = f011helper t u v xs
>
> f011helper :: Int -> Int -> Int -> [Int] -> Int
> f011helper t u v (w:ws)
>   | ws == []  = t*u*v*w
>   | otherwise = yada nada mada
>
> -- What are yada nada mada?
>
> -- The 20x20 grid case will become:
> f0112D :: [[Int]] -> Int
> -- where [[Int]] is a list of lists of rows, columns, major diagonals,
> & minor diagonals.
>
>
>
> On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso  wrote:
>> No. The answer I posted is not good.
>> It worked, by chance, on a couple of small examples I tried but it
>> could end up comparing sequence of 4 numbers that where not initially
>> adjacent.
>>
>> On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso  
>> wrote:
>>> Maybe this?
>>>
>>> f x@(a:b:c:d:[]) = x
>>> f (a:b:c:d:e:ys)  = if e >= a
>>>                   then f (b:c:d:e:ys)
>>>                   else f (a:b:c:d:ys)
>>>
>>> On Sat, Aug 27, 2011 at 8:26 PM, KC  wrote:
 Think of the simplest version of the problem that isn't totally trivial.

 e.g. A one dimensional list of numbers.

 What would you do?

 Note: you only want to touch each element once.

 The 2 dimensional case could be handled by putting into lists: rows,
 columns, major diagonals, and minor diagonals.

 This isn't the fastest way of doing the problem but it has the
 advantage of avoiding "indexitis".


>
>
> --
> --
> Regards,
> KC
>



-- 
--
Regards,
KC

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


[Haskell-cafe] Unexpected Typeable behaviour; Prelude.undefined

2011-08-28 Thread Philip Holzenspies
L.S.,

I'm currently writing code where I want some ADTs to be parametric with a 
monad. There are some extra conditions that I place on my parameter, but I've 
boiled things down to minimal reproducibility. When I define MyADT as follows:


import Data.Typeable

data MyADT m = MyADT (m ())

instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
typeOf t@(MyADT _)
 = mkTyCon "MyADT"
  `mkTyConApp`
  [typeOf1 ((return :: Monad m => MyADT m -> m (MyADT m)) t)]


it compiles fine and GHCi works as expected on a single instance of MyADT:


*Main> typeOf (MyADT (return () :: IO ()))
MyADT IO


However, as soon as I place my data type in a structure of sorts, things break 
down:


*Main> typeOf [(MyADT (return () :: IO ()))]
*** Exception: Prelude.undefined
*Main> typeOf (Just (MyADT (return () :: IO (
*** Exception: Prelude.undefined
*Main> typeOf ((return :: a -> IO a) (MyADT (return () :: IO (
*** Exception: Prelude.undefined


But if I stick a number in a similar structure, typeOf works just fine:


*Main> typeOf ((return :: a -> IO a) 5)
IO Integer


I don't quite understand where  the undefined comes from. I'm certainly not 
using it anywhere (as shown by the minimal reproduction above). Weirder still, 
when I *do* introduce a nice error, that too does not come up, viz.


import Data.Typeable

data MyADT m = MyADT (m ())
instance (Typeable1 m, Monad m) => Typeable (MyADT m) where
typeOf t@(MyADT _)
 = error "foobar"


with GHCi-session:


*Main> typeOf (MyADT (return () :: IO ()))
*** Exception: foobar
*Main> typeOf ((return :: a -> IO a) (MyADT (return () :: IO (
*** Exception: Prelude.undefined
*Main> typeOf $ Just (MyADT (return () :: IO ()))
*** Exception: Prelude.undefined
*Main> typeOf $ Just 42
Maybe Integer


FYI, I'm using GHC 7.0.3, as installed with the Haskell Platform 2011.2.0.1. Am 
I overlooking something? Any help would be appreciated.

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


[Haskell-cafe] Bug in GC's ordering of ForeignPtr finalization?

2011-08-28 Thread Ben Gamari
On Tue, 16 Aug 2011 12:32:13 -0400, Ben Gamari  wrote:
> It seems that the notmuch-haskell bindings (version 0.2.2 built against
> notmuch from git master; passes notmuch-test) aren't dealing with memory
> management properly. In particular, the attached test code[1] causes
> talloc to abort.  Unfortunately, while the issue is consistently
> reproducible, it only occurs with some queries (see source[1]). I have
> been unable to establish the exact criterion for failure.
> 
> It seems that the crash is caused by an invalid access to a freed Query
> object while freeing a Messages object (see Valgrind trace[3]). I've
> taken a brief look at the bindings themselves but, being only minimally
> familiar with the FFI, there's nothing obviously wrong (the finalizers
> passed to newForeignPtr look sane). I was under the impression that
> talloc was reference counted, so the Query object shouldn't have been
> freed unless if there was still a Messages object holding a
> reference. Any idea what might have gone wrong here?  Thanks!
> 
After looking into this issue in a bit more depth, I'm even more
confused. In fact, I would not be surprised if I have stumbled into a
bug in the GC. It seems that the notmuch-haskell bindings follow the
example of the python bindings in that child objects keep references to
their parents to prevent the garbage collector from releasing the
parent, which would in turn cause talloc to free the child objects,
resulting in odd behavior when the child objects were next accessed. For
instance, the Query and Messages objects are defined as follows,

type MessagesPtr = ForeignPtr S__notmuch_messages
type MessagePtr = ForeignPtr S__notmuch_message
newtype Query = Query (ForeignPtr S__notmuch_query)
data MessagesRef = QueryMessages { qmpp :: Query, msp :: MessagesPtr }
 | ThreadMessages { tmpp :: Thread, msp :: MessagesPtr }
 | MessageMessages { mmspp :: Message, msp :: MessagesPtr }
data Message = MessagesMessage { msmpp :: MessagesRef, mp :: MessagePtr }
 | Message { mp :: MessagePtr }
type Messages = [Message]

As seen in the Valgrind dump given in my previous message, it seems that
the Query object is being freed before the Messages object. Since the
Messages object is a child of the Query object, this fails.

In my case, I'm calling queryMessages which begins by issuing a given
notmuch Query, resulting in a MessagesPtr. This is then packaged into a
QueryMessages object which is then passed off to
unpackMessages. unpackMessages iterates over this collection, creating
MessagesMessage objects which themselves refer to the QueryMessages
object. Finally, these MessagesMessage objects are packed into a list,
resulting in a Messages object. Thus we have the following chain of
references,

MessagesMessage
  |   
  |  msmpp
  \/
QueryMessages
  |
  |  qmpp
  \/
Query

As we can see, each MessagesMessage object in the Messages list
resulting from queryMessages holds a reference to the Query object from
which it originated. For this reason, I fail to see how it is possible
that the RTS would attempt to free the Query before freeing the
MessagesPtr. Did I miss something in my analysis? Are there tools for
debugging issues such as this? Perhaps this is a bug in the GC?

Any help at all would be greatly appreciated.

Cheers,

- Ben

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-28 Thread KC
Try something like the following:

-- Project Euler 11

-- In the 20×20 grid below, four numbers along a diagonal line have
been marked in red.

-- 

-- The product of these numbers is 26 × 63 × 78 × 14 = 1788696.

-- What is the greatest product of four adjacent numbers in any
direction (up, down, left, right, or diagonally) in the 20×20 grid?


import Data.List

-- Doing the one dimensional case.
f011 :: [Int] -> Int
f011 (t:u:v:xs) = f011helper t u v xs

f011helper :: Int -> Int -> Int -> [Int] -> Int
f011helper t u v (w:ws)
   | ws == []  = t*u*v*w
   | otherwise = yada nada mada

-- What are yada nada mada?

-- The 20x20 grid case will become:
f0112D :: [[Int]] -> Int
-- where [[Int]] is a list of lists of rows, columns, major diagonals,
& minor diagonals.



On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso  wrote:
> No. The answer I posted is not good.
> It worked, by chance, on a couple of small examples I tried but it
> could end up comparing sequence of 4 numbers that where not initially
> adjacent.
>
> On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso  
> wrote:
>> Maybe this?
>>
>> f x@(a:b:c:d:[]) = x
>> f (a:b:c:d:e:ys)  = if e >= a
>>                   then f (b:c:d:e:ys)
>>                   else f (a:b:c:d:ys)
>>
>> On Sat, Aug 27, 2011 at 8:26 PM, KC  wrote:
>>> Think of the simplest version of the problem that isn't totally trivial.
>>>
>>> e.g. A one dimensional list of numbers.
>>>
>>> What would you do?
>>>
>>> Note: you only want to touch each element once.
>>>
>>> The 2 dimensional case could be handled by putting into lists: rows,
>>> columns, major diagonals, and minor diagonals.
>>>
>>> This isn't the fastest way of doing the problem but it has the
>>> advantage of avoiding "indexitis".
>>>
>>>


-- 
--
Regards,
KC

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


Re: [Haskell-cafe] Make shared library - questions

2011-08-28 Thread David Banas

> I'm trying to compile shared library. This library will use as part of
> plugin for some program.
> If I compile library with option -dynamic my library has links for HS
> libraries like libHSbase-4.2.0.2-ghc6.12.3.so and so on.
> But program has crashed constantly.
> 
> Is it possible to make shared library without -dynamic flag? I want to
> try
> to make library without dependencies.

I struggled with this, too.
Here's my makefile, which is now working:

  1 GCC = gcc
  2 CFLAGS += -I/usr/lib/ghc-6.12.3/include/ -g -fPIC
  3 
  4 HC  = ghc
  5 HC_OPTS = -cpp $(EXTRA_HC_OPTS)
  6 EXTRA_HC_OPTS = -package parsec
  7 HC_LOPTS = -no-hs-main -shared -package parsec
  8 #GHCOPTS := -prof -auto-all -caf-all
  9 
 10 HSRCS = AMIParse.hs AMIModel.hs ApplicativeParsec.hs
 11 CSRCS = ami_model.c ami_test.c
 12 SRCS  = $(HSRCS) $(CSRCS)
 13 OBJS = AMIParse.o  AMIModel.o  ami_model.o AMIModel_stub.o
ApplicativeParsec.o
 14 
 15 .SUFFIXES : .o .hs .hi .lhs .hc .s .c
 16 .PHONY : all depend rebuild clean
 17 
 18 all: ami_test
 19 
 20 ami_test: ami_test.o libami.so
 21 $(HC) -dynamic -o $@ -L. -lami ami_test.o
 22 
 23 libami.so : $(OBJS)
 24 rm -f $@
 25 $(HC) -o $@ $(HC_LOPTS) $^
 26 
 27 depend:
 28 $(HC) -M $(HC_OPTS) $(HSRCS)
 29 
 30 rebuild:
 31 $(MAKE) clean
 32 $(MAKE) all
 33 
 34 clean:
 35 rm -f *.hi *.o *.out ami_test *.so
 36 
 37 # Standard suffix rules
 38 .o.hi:
 39 @:
 40 
 41 .lhs.o:
 42 $(HC) -c $< $(HC_OPTS)
 43 
 44 .hs.o:
 45 $(HC) -c $< $(HC_OPTS)
 46 
 47 .o-boot.hi-boot:
 48 @:
 49 
 50 .lhs-boot.o-boot:
 51 $(HC) -c $< $(HC_OPTS)
 52 
 53 .hs-boot.o-boot:
 54 $(HC) -c $< $(HC_OPTS)
 55 
 56 # Individual cases
 57 AMIModel_stub.o: AMIModel.hs
 58 $(HC) -c $< $(HC_OPTS)
 59 
 60 # DO NOT DELETE: Beginning of Haskell dependencies
 61 ApplicativeParsec.o : ApplicativeParsec.hs
 62 AMIParse.o : AMIParse.hs
 63 AMIParse.o : ApplicativeParsec.hi
 64 AMIModel.o : AMIModel.hs
 65 AMIModel.o : AMIParse.hi
 66 # DO NOT DELETE: End of Haskell dependencies

Good luck!
-db



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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Brandon Allbery
On Sun, Aug 28, 2011 at 16:40, Arnaud Bailly  wrote:

> Thanks for taking the time to help me fix this package stuff. So I wiped
> out my package.conf.d/ and tried to reinstall my stuff. Installing
> template-haskell 2.5.0.0 is ok (2.6 is not, fails to compile on ghc 7.0.3)
> but then:
>
> D:\projets\>ghc --make -package ghc main
>
> : cannot satisfy -package ghc
> (use -v for more information)
>

That'd be expected; you shouldn't simply obliterate package.conf.d, you need
to keep ghc's boot libraries (which include itself as a library).  If the
boot libraries are somehow hosed, you need to reinstall the compiler to get
them back.

Although, I think you were headed there anyway:  template-haskell is a boot
library, since it's very tightly bound to the exact compiler version, so
it's almost always wrong to install it in any way other than as part of
installing GHC itself.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell-src-exts should depend on happy

2011-08-28 Thread Niklas Broberg
On Thu, Aug 25, 2011 at 6:17 PM, Brent Yorgey wrote:

> On Thu, Aug 25, 2011 at 04:47:30PM +0100, Ozgur Akgun wrote:
> > Hi,
> >
> > cabal installing haskell-src-exts fails, because of an unlisted
> dependency
> > to the happy executable.
>
> It does list a dependency on happy:
>
>Build-Tools:  happy >= 1.17
>
> If I understand correctly, the problem is that cabal does not track
> packages which only install executables.  So all it can do is give an
> error if a 'happy' executable is not found; there is no way to have it
> automatically install happy if it is not.  This is a well-known
> limitation of cabal-install rather than a problem with the
>  haskell-src-exts package in particular.


Yep, what Brent said. See this ticket:
http://trac.haskell.org/haskell-src-exts/ticket/59

Cheers,

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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-28 Thread Arnaud Bailly
Hello Albert,
Thanks for taking the time to help me fix this package stuff. So I wiped out
my package.conf.d/ and tried to reinstall my stuff. Installing
template-haskell 2.5.0.0 is ok (2.6 is not, fails to compile on ghc 7.0.3)
but then:

D:\projets\>ghc --make -package ghc main
: cannot satisfy -package ghc
(use -v for more information)

I suspect I really *do* have to reinstall haskell-platform. Here is the
output of ghc-pkg list -v:

using cache: C:\Documents and Settings\abailly\Application
Data\ghc\i386-mingw32-7.0.3\package.conf.d\package.cache
using cache: D:/Program Files/Haskell
Platform/2011.2.0.1\lib\package.conf.d\package.cache
D:/Program Files/Haskell Platform/2011.2.0.1\lib\package.conf.d:
Cabal-1.10.1.0 (Cabal-1.10.1.0-55f781465ee9f32289755ad706c71f0f)
GLUT-2.1.2.1 (GLUT-2.1.2.1-2d30997b9a19d27be388572e75af52bf)
HTTP-4000.1.1 (HTTP-4000.1.1-267a332938fa742ba5a5d59de0b46d60)
HUnit-1.2.2.3 (HUnit-1.2.2.3-102fbfbd594cd6d38461f5c68d880996)
OpenGL-2.2.3.0 (OpenGL-2.2.3.0-a58ce3ad6070e6b7932a3e779be57f75)
Win32-2.2.0.1 (Win32-2.2.0.1-26cf39fdf591bdac61b11d5a443c62ab)
array-0.3.0.2 (array-0.3.0.2-8e9cd0144e87fa9cc86cc9031631c4f3)
base-4.3.1.0 (base-4.3.1.0-f520cd232cc386346843c4a12b63f44b)
bin-package-db-0.0.0.0
(bin-package-db-0.0.0.0-97d865e5935b41538bcb29fc1040ae7d)
bytestring-0.9.1.10
(bytestring-0.9.1.10-cd85f14e02463c02ba4c77d7adcdb54f)
cgi-3001.1.7.4 (cgi-3001.1.7.4-659440ce11c2975fd9c9c471a1e8ff3b)
containers-0.4.0.0 (containers-0.4.0.0-18deac99a132f04751d862b77aab136e)
deepseq-1.1.0.2 (deepseq-1.1.0.2-09b3aed0c4982bbc6569c668100876fa)
directory-1.1.0.0 (directory-1.1.0.0-3a2367d72569467a8af8a231656ff1b8)
extensible-exceptions-0.1.1.2
(extensible-exceptions-0.1.1.2-d8c5b906654260efd7249f497d17a831)
ffi-1.0 (builtin_ffi)
fgl-5.4.2.3 (fgl-5.4.2.3-595811d6eabb1e1768685703ea66e982)
filepath-1.2.0.0 (filepath-1.2.0.0-f132e9f7703da4e20a47ff2b9acf1ea1)
(ghc-binary-0.5.0.2
(ghc-binary-0.5.0.2-aba2b5dca5546ea1a972188de48f87b5))
ghc-prim-0.2.0.0 (ghc-prim-0.2.0.0-e1f7c380581d61d42b0360d440cc35ed)
haskell-src-1.0.1.4
(haskell-src-1.0.1.4-7428a8c9049cd6bf5abdc0bbd2d417c5)
(haskell2010-1.0.0.0
(haskell2010-1.0.0.0-53d9cd65595c551eea0c0269f534b5e0))
haskell98-1.1.0.1 (haskell98-1.1.0.1-35ec26bae828637c1638c8be441b3d68)
hpc-0.5.0.6 (hpc-0.5.0.6-481dbb43fb624c21ad3bb9434675e3ac)
html-1.0.1.2 (html-1.0.1.2-a494249f98a0f38b1a8db28bc70f8b0b)
integer-gmp-0.2.0.3
(integer-gmp-0.2.0.3-91607778cf3ae8f3948a50062b4f8479)
mtl-2.0.1.0 (mtl-2.0.1.0-fb4d1695269b74308c1517c06b76e6e8)
network-2.3.0.2 (network-2.3.0.2-47657e39a6118a978d9f443d72e85d4a)
old-locale-1.0.0.2 (old-locale-1.0.0.2-6e2a3c0744e8cf4e0ac2d4e58659f7b5)
old-time-1.0.0.6 (old-time-1.0.0.6-445ce39cbcebd38069c25c0f383b728d)
parallel-3.1.0.1 (parallel-3.1.0.1-6eaa564e1ef1537bc88ad1fea6c90fe2)
parsec-3.1.1 (parsec-3.1.1-9da59b00c02e52f9f62f3c87c7e0e2ec)
pretty-1.0.1.2 (pretty-1.0.1.2-abc7c632374e50e1c1927987c2651f0f)
process-1.0.1.5 (process-1.0.1.5-b3dded8e54a2e13d22af410bdcfafff4)
random-1.0.0.3 (random-1.0.0.3-1abde37180be5476311abeefe300abc2)
regex-base-0.93.2 (regex-base-0.93.2-9e1b027c41dbec856469a30982495bb9)
regex-compat-0.93.1
(regex-compat-0.93.1-31c61fe0aee45e8a9853edf7a844f74e)
regex-posix-0.94.4 (regex-posix-0.94.4-f5eb628ea5dae5f91552d5ea0e26359d)
rts-1.0 (builtin_rts)
stm-2.2.0.1 (stm-2.2.0.1-57e291244ee02349552a4f79caeb4ffe)
syb-0.3 (syb-0.3-8db7bc4339a1cb8a6f2a46c40447ef0b)
text-0.11.0.6 (text-0.11.0.6-398a3f02891247aea46662fc7379c4a5)
time-1.2.0.3 (time-1.2.0.3-74ef6ac31cee9aec02b036978af002d2)
transformers-0.2.2.0
(transformers-0.2.2.0-2fe7b735c63a6cbe8724038d8e4d812a)
xhtml-3000.2.0.1 (xhtml-3000.2.0.1-ace31b2e48c396e565655b0f34f5d2b7)
zlib-0.5.3.1 (zlib-0.5.3.1-5fbdf714525b76e0e601c2ffb25f2044)

C:\Documents and Settings\abailly\Application
Data\ghc\i386-mingw32-7.0.3\package.conf.d:
QuickCheck-2.4.1.1 (QuickCheck-2.4.1.1-04d68679694a517ba23022a4c6bc1cde)
ghc-paths-0.1.0.8 (ghc-paths-0.1.0.8-be391faf057d651dbb92b73671fe9eee)
template-haskell-2.5.0.0
(template-haskell-2.5.0.0-87f4f416a22a910e480ac9f269479a5f)
utf8-string-0.3.7 (utf8-string-0.3.7-dcbcb8de655cdfe1c4c28c094f8c6799)

Thanks again,
Arnaud

On Sat, Aug 27, 2011 at 8:59 PM, Albert Y. C. Lai  wrote:

> You have too many instances of template-haskell. The important parts are:
>
>
> package ghc-7.0.3-**fc75cf67c86ba2c0d64b07024a18d3**b4 is unusable due to
> missing or recursive dependencies:
>  template-haskell-2.5.0.0-**7d9b1443ac5ab69e5ed705a487990d**eb
>
> package template-haskell-2.5.0.0-**7d9b1443ac5ab69e5ed705a487990d**eb is
> shadowed by package template-haskell-2.5.0.0-**
> 87f4f416a22a910e480ac9f269479a**5f
>
> and in "ghc-pkg list -v":
>
> D:/Program Files/Haskell Platform/2011.2.0.1\lib\**package.conf.d:
>
>
>   template-haskell-2.5.0.0 (template-haskell-2.5.0.0-**
> 7

Re: [Haskell-cafe] Class instances in haddock documentation missing

2011-08-28 Thread Joachim Breitner
Hi again,

sorry for bumping this, but it is really annoying and I don’t even know
where to start looking for the cause of the problem.

Am Sonntag, den 19.06.2011, 14:00 +0200 schrieb Joachim Breitner:
> the haddock information generated on hackage lists class instances per
> class and per data type e.g. on
> http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/Data-Eq.html
> or
> http://hackage.haskell.org/packages/archive/xhtml/3000.2.0.1/doc/html/Text-XHtml-Transitional.html
> 
> For some reason, the documentation generated on Debian does not. Does
> anybody have an idea why that could be? We use
>   ./Setup haddock --hyperlink-source
> to build the documentation, using the haddock that is shipped with ghc
> (2.9.2 at the moment).

Thanks,
Joachim
-- 
Joachim "nomeata" Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHCI Feature Request: Last SuccessfulCompilation State Saved

2011-08-28 Thread Daniel Fischer
On Sunday 28 August 2011, 20:43:11, Rene de Visser wrote:
> "Daniel Fischer"  schrieb im
> Newsbeitrag news:201108272331.01371.daniel.is.fisc...@googlemail.com...
> 
> > On Saturday 27 August 2011, 23:10:17, David Virebayre wrote:
> >> 2011/8/27 aditya siram :
> >> > Hi all,
> >> > I would like for the GHCI interpreter to save its environment
> >> > before reloading a file and allowed the user to revert back to
> >> > that state if the compilation was unsuccessful.
> >> 
> >> That would be awesome. I would like this too.
> > 
> > http://hackage.haskell.org/trac/ghc/ticket/1896
> 
> +1 from me too.
> 
> How do I go about registering my interest in the ticket?
> I though there was a way of adding myself on the CC: of the ticket?
> How does one do this? Does one need some sort of user?

You need to log in to add yourself to the cc.
If you don't have a trac account and don't want one, at the bottom of the 
page, on the right hand side, there's a pale text telling you how to log in 
with the guest account.

Cheers,
Daniel

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


Re: [Haskell-cafe] GHCI Feature Request: Last SuccessfulCompilation State Saved

2011-08-28 Thread Rene de Visser
"Daniel Fischer"  schrieb im Newsbeitrag 
news:201108272331.01371.daniel.is.fisc...@googlemail.com...
> On Saturday 27 August 2011, 23:10:17, David Virebayre wrote:
>> 2011/8/27 aditya siram :
>> > Hi all,
>> > I would like for the GHCI interpreter to save its environment before
>> > reloading a file and allowed the user to revert back to that state if
>> > the compilation was unsuccessful.
>>
>> That would be awesome. I would like this too.
>
> http://hackage.haskell.org/trac/ghc/ticket/1896

+1 from me too.

How do I go about registering my interest in the ticket?
I though there was a way of adding myself on the CC: of the ticket?
How does one do this? Does one need some sort of user?

Rene. 




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


Re: [Haskell-cafe] GHC API question

2011-08-28 Thread Chris Smith
On Sun, 2011-08-28 at 17:47 +0100, Thomas Schilling wrote:
> I don't think you can link GHCi with binaries compiled in profiling
> mode.  You'll have to build an executable.

Okay... sorry to be obtuse, but what exactly does this mean?  I'm not
using GHCi at all: I *am* in an executable built with profiling info.

I'm doing this:

dflags <- GHC.getSessionDynFlags
let dflags' = dflags {
GHC.ghcMode = GHC.CompManager,
GHC.ghcLink = GHC.LinkInMemory,
GHC.hscTarget = GHC.HscAsm,
GHC.optLevel = 2,
GHC.safeHaskell = GHC.Sf_Safe,
GHC.packageFlags = [GHC.TrustPackage "gloss" ],
GHC.log_action = addErrorTo codeErrors
}
GHC.setSessionDynFlags dflags'
target <- GHC.guessTarget filename Nothing
GHC.setTargets [target]
r  <- fmap GHC.succeeded (GHC.load GHC.LoadAllTargets)

and then if r is true:

mods <- GHC.getModuleGraph
let mainMod = GHC.ms_mod (head mods)
Just mi <- GHC.getModuleInfo mainMod
let tyThings = GHC.modInfoTyThings mi
let var = chooseTopLevel varname tyThings
session <- GHC.getSession
v   <- GHC.liftIO $ GHC.getHValue session (GHC.varName var)
return (unsafeCoerce# v)

Here, I know that chooseTopLevel is working, but the getHValue part only
works without profiling.  So is this still hopeless, or do I just need
to find the right additional flags to add to dflags'?

-- 
Chris Smith



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


Re: [Haskell-cafe] GHC API question

2011-08-28 Thread Thomas Schilling
I don't think you can link GHCi with binaries compiled in profiling
mode.  You'll have to build an executable.

On 28 August 2011 16:38, Chris Smith  wrote:
> Okay, I should have waited until morning to post this... so actually,
> things still work fine when I build without profiling.  However, when I
> build with profiling, I get the segfault.  I'm guessing either I need to
> set different dynamic flags with the profiling build to match the
> options of the compiler that built the executable... or perhaps it's
> still impossible to do what I'm looking for with profiling enabled.
> Does anyone know which is the case?
>
> --
> Chris
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Push the envelope. Watch it bend.

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


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Maciej Marcin Piechotka
On Sun, 2011-08-28 at 11:48 -0300, Felipe Almeida Lessa wrote:
> On Sun, Aug 28, 2011 at 7:41 AM, Tony Morris  wrote:
> > Pointed f => Pointed (StateT s f)
> >
> > but not
> >
> > Applicative f => Applicative (StateT s f)
> 
> But we do have
> 
> (Functor m, Monad m) => Applicative (StateT s m)
> 
> so I'm not sure if this is a valid example.
> 
> Cheers,
> 

newtype StateT s m a = StateT (s -> m (a, s))

instance Functor m => Functor (StateT s m) where
  f `fmap` StateT g = StateT $ fmap (first f) . g

instance Pointed m => Pointed (StateT s m) where
  point x = StateT $ point . (,) x

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC API question

2011-08-28 Thread Chris Smith
Okay, I should have waited until morning to post this... so actually,
things still work fine when I build without profiling.  However, when I
build with profiling, I get the segfault.  I'm guessing either I need to
set different dynamic flags with the profiling build to match the
options of the compiler that built the executable... or perhaps it's
still impossible to do what I'm looking for with profiling enabled.
Does anyone know which is the case?

-- 
Chris


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


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Felipe Almeida Lessa
On Sun, Aug 28, 2011 at 7:41 AM, Tony Morris  wrote:
> Pointed f => Pointed (StateT s f)
>
> but not
>
> Applicative f => Applicative (StateT s f)

But we do have

(Functor m, Monad m) => Applicative (StateT s m)

so I'm not sure if this is a valid example.

Cheers,

-- 
Felipe.

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


[Haskell-cafe] Trouble with Haddock

2011-08-28 Thread anonymous
First time using haddock.
I'm unable to include code examples in the module header.
Haddock fails with this error:
haddock module header parse failed: Cannot parse header
documentation paragraphs

It's about 12 lines of code, which doesn't seem like much compared to other
packages.

e.g.
-- | describing module
--
-- > code
-- > ...
-- > code
module Foo
   ( 


I tried @...@ code blocks, but that didn't work either.
If I shorten the code to 3 lines or so, it will work.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28/08/11 01:41, Sönke Hahn wrote:
> Hi!
> 
> I was reading through the Typeclassopedia ([1]) and I was wondering which 
> type could be an instance of Pointed, but not of Applicative. But I can't 
> think of one. Any ideas?
> 
> Sönke
> 
> [1] http://www.haskell.org/haskellwiki/Typeclassopedia
> 
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Pointed f => Pointed (StateT s f)

but not

Applicative f => Applicative (StateT s f)

- -- 
Tony Morris
http://tmorris.net/

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOWhtaAAoJEPxHMY3rBz0Pa3oIAMrqoyv4DW39VjIXwzV3/4Ir
W5s0+fdoPj7h1j6eyCB81VcDHNtGQmWhZ3+g2AhHo1jLAzmH8G5ACdD1c1FeF2dn
a0iO7uvH5sM0xovpsqUwZC8BkomdeAnRuYF5Ohzar5M/Ip2BD0k7QpIWJt3RdLZm
uCpwDnsQ2foHJCJYlGmmGkpzDAnkwePOfER93KrKXmzHqQxhS0oACQy6LKfXODTM
+d2VVzzb4tWuzijXE4NflpdtW/4jSs3gVFmkZ7BmXSg8XxZO3naO/y4gtrU4YVjw
7TKo4IOIygQVMsFbdV2WZHprMHU/VaM6MTByiNECyB0q/yhJhsXtGsd9eeR2jng=
=X4nM
-END PGP SIGNATURE-

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


[Haskell-cafe] Pointed, but not Applicative

2011-08-28 Thread Sönke Hahn
Hi!

I was reading through the Typeclassopedia ([1]) and I was wondering which 
type could be an instance of Pointed, but not of Applicative. But I can't 
think of one. Any ideas?

Sönke

[1] http://www.haskell.org/haskellwiki/Typeclassopedia


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