[tor-dev] PRELIMINARY [PATCH 2/2] Remove a redundant instance declaration.

Nikita Karetnikov nikita at karetnikov.org
Mon Jul 8 15:53:36 UTC 2013


> We use the main repositories only for released versions.  FOr
> development branches, we use pesonal repositories.  Most people find
> that it's more convenient to use a service like github or gitorious or
> something to host their own branches, and then ask for review and
> merging when the branches are ready for review and merging.

> It's okay to send stuff to the list, but linking to a public branch
> and listing the commit IDs usually works as well as sending patches.

I don't have a server that I can physically control, and I'm trying to
avoid third party services.  Most of them use freedom-denying
software.  Moreover, companies might decide to shut them down for some
reason.  Imagine that I also won't be able to provde the needed code
in that case.  That would be very frustrating.

Lists are usually mirrored, plus subscribers might have local copies.
That's why I'd prefer to send patches to the list.  If anyone finds
that inconvenient, I'll try to find a workaround.

I'm attaching two preliminary patches.  I'm more confident about them
than the previous ones.  Still, I can't build the program or run the
tests, so you shouldn't expect them to work.

'0002-Remove-a-redundant-instance-declaration.patch' is
self-explanatory.  (I set 'network' to '>=2.4.0.0' because it's the
first version that derives 'Ord'.)

If you want to test the other patch, copy the functions to 'Test.hs'
and run the following:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
$ ghci Test.hs
*Main> import Data.Dynamic (toDyn, fromDynamic)
*Main Data.Dynamic> E.tryJust syncExceptions $ E.throwIO E.DivideByZero
Left divide by zero
*Main Data.Dynamic> E.tryJust syncExceptions $ E.throwIO E.StackOverflow
*** Exception: stack overflow
*Main Data.Dynamic> ignoreJust syncExceptions $ E.throwIO E.StackOverflow
*** Exception: stack overflow
*Main Data.Dynamic> ignoreJust syncExceptions $ E.throwIO E.DivideByZero
*Main Data.Dynamic> showException [fromDynamic] $ E.toException $ toDyn "foo"
"foo"
*Main Data.Dynamic> showException [fromDynamic] $ E.toException E.DivideByZero
"divide by zero"
*Main Data.Dynamic> showException [fromDynamic, (return . show)] $ E.toException $ toDyn "foo"
"foo"
*Main Data.Dynamic> showException [fromDynamic, (return . show)] $ E.toException $ E.DivideByZero
"divide by zero"

If you want to test the original code (using GHC 6.10.4), you should
adjust some functions:

*Main> showException [fromDynamic] $ E.DynException $ toDyn "foo"
"foo"
*Main> showException [fromDynamic] $ E.ArithException E.DivideByZero
"divide by zero"
*Main> showException [fromDynamic, (return . show)] $ E.DynException $ toDyn "foo"
"foo"
*Main> showException [fromDynamic, (return . show)] $ E.ArithException E.DivideByZero
"divide by zero"

Did I forget any corner cases?

I tried to write tests for the above, but it didn't work well with
HUnit.  Should I try QuickCheck?  I guess we don't want to depend on
two testing libraries, do we?

If you apply the attached patches on top of [1] and [2], you should get
the following:

$ ./Setup.lhs configure --user
$ ./Setup.lhs build

[...]

[ 4 of 39] Compiling TorDNSEL.Util    ( dist/build/tordnsel/tordnsel-tmp/TorDNSEL/Util.hs, dist/build/tordnsel/tordnsel-tmp/TorDNSEL/Util.o )

src/TorDNSEL/Util.hsc:143:1: Warning:
    Module `GHC.IOBase' is deprecated: use GHC.IO instead

src/TorDNSEL/Util.hsc:380:47: Warning:
    In the use of `B.findSubstrings'
    (imported from Data.ByteString.Char8, but defined in Data.ByteString):
    Deprecated: "findSubstrings is deprecated in favour of breakSubstring."
[ 7 of 39] Compiling TorDNSEL.Random  ( src/TorDNSEL/Random.hs, dist/build/tordnsel/tordnsel-tmp/TorDNSEL/Random.o )

src/TorDNSEL/Random.hs:39:1:
    Unacceptable argument type in foreign declaration: CInt
    When checking declaration:
      foreign import ccall unsafe "static openssl/rand.h RAND_bytes" c_RAND_bytes
        :: Ptr Word8 -> CInt -> IO CInt

src/TorDNSEL/Random.hs:39:1:
    Unacceptable result type in foreign declaration: IO CInt
    When checking declaration:
      foreign import ccall unsafe "static openssl/rand.h RAND_bytes" c_RAND_bytes
        :: Ptr Word8 -> CInt -> IO CInt

src/TorDNSEL/Random.hs:59:1:
    Unacceptable argument type in foreign declaration: CInt
    When checking declaration:
      foreign import ccall unsafe "static openssl/rand.h RAND_seed" c_RAND_seed
        :: Ptr Word8 -> CInt -> IO ()

src/TorDNSEL/Random.hs:65:1:
    Unacceptable result type in foreign declaration: IO CInt
    When checking declaration:
      foreign import ccall unsafe "static openssl/rand.h RAND_status" c_RAND_status
        :: IO CInt

It's also necessary to fix exceptions in other modules (run 'grep -r
Exception src').

Any comments?

[1] http://lists.torproject.org/pipermail/tor-dev/attachments/20130622/3e84acaf/attachment.patch
[2] http://lists.torproject.org/pipermail/tor-dev/attachments/20130619/34418869/attachment.patch

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Replace-TorDNSEL.Compat.Exception-with-Control.Excep.patch
Type: text/x-diff
Size: 2523 bytes
Desc: not available
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20130708/9325df85/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Remove-a-redundant-instance-declaration.patch
Type: text/x-diff
Size: 1706 bytes
Desc: not available
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20130708/9325df85/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.torproject.org/pipermail/tor-dev/attachments/20130708/9325df85/attachment.sig>


More information about the tor-dev mailing list