Re: [Haskell-cafe] ANN: data-fix-cse -- Common subexpression elimination for EDSLs

2013-02-23 Thread Anton Kholomiov
I don't know how to express it. You need to have some dynamic
representation since
dag is a container of `(Int, f Int)`. I've tried to go along this road

type Exp a = Fix (E a)

data E c :: * -> * where
  Lit :: Show a => a -> E a c
  Op  :: Op a -> E a c
  App :: Phantom (a -> b) c -> Phantom a c -> E b c

data Op :: * -> * where
  Add :: Num a => Op (a -> a -> a)
  Mul :: Num a => Op (a -> a -> a)
  Neg :: Num a => Op (a -> a)

newtype Phantom a b = Phantom { unPhantom :: b }

But got stuck with the definition of

app :: Exp (a -> b) -> Exp a -> Exp b
app f a = Fix $ App (Phantom f) (Phantom a)

App requires the arguments to be of the same type (in the second type
argument `c`).

2013/2/23 Conal Elliott 

>
> On Tue, Feb 19, 2013 at 9:28 PM, Anton Kholomiov <
> anton.kholom...@gmail.com> wrote:
>
>>
>> Do you think the approach can be extended for non-regular (nested)
>>> algebraic types (where the recursive data type is sometimes at a different
>>> type instance)? For instance, it's very handy to use GADTs to capture
>>> embedded language types in host language (Haskell) types, which leads to
>>> non-regularity.
>>>
>>>
>> I'm not sure I understand the case you are talking about. Can you write a
>> simple example
>> of the types like this?
>>
>
> Here's an example of a type-embedded DSEL, represented as a GADT:
>
> > data E :: * -> * where
> >   Lit :: Show a => a -> E a
> >   Op  :: Op a -> E a
> >   App :: E (a -> b) -> E a -> E b
> >   ...
> >
> > data Op :: * -> * where
> >   Add :: Num a => E (a -> a -> a)
> >   Mul :: Num a => E (a -> a -> a)
> >   Neg :: Num a => E (a -> a)
> >   ...
>
> -- Conal
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
Hi,

I am trying to use Haskell to download email/attachments from gmail. For
which I am exploring Network.TLS. I got this sample from the net that
connects to gmail smtp and works just fine -
http://hpaste.org/82890

However, when I modify it a bit to try to connect to imap, it simply does
not work. To debug, I tried to connect to a webserver, even that seems to
not work. I modified the function as follows.


emailGmail2 = do
let host = "localhost"
let port = 443
let params = defaultParamsClient{pCiphers = ciphers}
g <- RNG.makeSystem
h <- connectTo host (PortNumber (fromIntegral port))
hSetBuffering h LineBuffering
cWrite h "GET / HTTP/1.0"
cWrite h ""
cWaitFor h "ABCD"
con <- contextNewOnHandle h params g
handshake con
bye con


And I get a "BAD request" response from the server - Can some please give
me a sample code that uses Network.TLS to connect to a imap.google.com (or
even a webserver for that matter)?

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


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread satvik chauhan
You can use HaskellNet  or
imapget  directly or look into
their source code for connecting to imap manually.

-Satvik

On Sat, Feb 23, 2013 at 8:58 PM, C K Kashyap  wrote:

> Hi,
>
> I am trying to use Haskell to download email/attachments from gmail. For
> which I am exploring Network.TLS. I got this sample from the net that
> connects to gmail smtp and works just fine -
> http://hpaste.org/82890
>
> However, when I modify it a bit to try to connect to imap, it simply does
> not work. To debug, I tried to connect to a webserver, even that seems to
> not work. I modified the function as follows.
>
>
> emailGmail2 = do
> let host = "localhost"
> let port = 443
> let params = defaultParamsClient{pCiphers = ciphers}
>  g <- RNG.makeSystem
> h <- connectTo host (PortNumber (fromIntegral port))
> hSetBuffering h LineBuffering
>  cWrite h "GET / HTTP/1.0"
> cWrite h ""
> cWaitFor h "ABCD"
>  con <- contextNewOnHandle h params g
> handshake con
> bye con
>
>
> And I get a "BAD request" response from the server - Can some please give
> me a sample code that uses Network.TLS to connect to a imap.google.com(or 
> even a webserver for that matter)?
>
> Regards,
> Kashyap
>
> ___
> 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] Type checking the content of a string

2013-02-23 Thread Corentin Dupont
Up on that, anybody already tried to load an haskell interpreter in a
QuasiQuoter?

On Sat, Feb 23, 2013 at 12:03 AM, Corentin Dupont  wrote:

> I'm trying to load my interpreter in the Q monad:
>
> cr :: QuasiQuoter
> cr = QuasiQuoter { quoteExp = quoteRuleFunc}
>
> quoteRuleFunc :: String -> Q TH.Exp
> quoteRuleFunc s = do
>res <- runIO $ runInterpreter $ do
>   setImports ["Prelude", "Language.Nomyx.Rule",
> "Language.Nomyx.Expression", "Language.Nomyx.Test",
>"Language.Nomyx.Examples", "GHC.Base", "Data.Maybe"]
>   interpret s (as :: RuleFunc)
>case res of
>   Right _ -> [| s |]
>   Left e -> fail $ show e
>
>
>  However, I always obtain an error durring compilation:
>
> ...
> Loading package XXX ... linking ... done.
>
>
> GHCi runtime linker: fatal error: I found a duplicate definition for symbol
>__stginit_ghczm7zi4zi1_DsMeta
> whilst processing object file
>/usr/lib/ghc/ghc-7.4.1/libHSghc-7.4.1.a
> This could be caused by:
>* Loading two different object files which export the same symbol
>* Specifying the same object file twice on the GHCi command line
>* An incorrect `package.conf' entry, causing some object to be
>  loaded twice.
> GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
>
>
> I vaguely understand that the interpreted modules are conflicting with the
> compiled ones...
>
>
>
> On Fri, Feb 22, 2013 at 11:51 PM, Corentin Dupont <
> corentin.dup...@gmail.com> wrote:
>
>> Great! That seems very powerful. So you can do what you want during
>> compilation, readin files, send data over the network?
>> Other question, in my example how can I halt the compilation if a test
>> program is wrong?
>>
>>
>> On Fri, Feb 22, 2013 at 8:30 PM, Francesco Mazzoli  wrote:
>>
>>> At Fri, 22 Feb 2013 19:43:51 +0100,
>>> Corentin Dupont wrote:
>>> > Hi Adam,
>>> > that looks interresting. I'm totally new to TH and QuasiQuotes, though.
>>> > Can I run IO in a QuasiQuoter? I can run my own interpreter.
>>>
>>> Yes, you can:
>>> <
>>> http://hackage.haskell.org/packages/archive/template-haskell/2.8.0.0/doc/html/Language-Haskell-TH.html#v:runIO
>>> >.
>>>
>>> Francesco
>>>
>>
>>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
The reason I want to use TLS is that I'd want to pack the whole thing in a
DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap


On Sat, Feb 23, 2013 at 10:46 PM, satvik chauhan wrote:

> You can use HaskellNet  or
> imapget  directly or look
> into their source code for connecting to imap manually.
>
> -Satvik
>
> On Sat, Feb 23, 2013 at 8:58 PM, C K Kashyap  wrote:
>
>> Hi,
>>
>> I am trying to use Haskell to download email/attachments from gmail. For
>> which I am exploring Network.TLS. I got this sample from the net that
>> connects to gmail smtp and works just fine -
>> http://hpaste.org/82890
>>
>> However, when I modify it a bit to try to connect to imap, it simply does
>> not work. To debug, I tried to connect to a webserver, even that seems to
>> not work. I modified the function as follows.
>>
>>
>> emailGmail2 = do
>> let host = "localhost"
>> let port = 443
>> let params = defaultParamsClient{pCiphers = ciphers}
>>  g <- RNG.makeSystem
>> h <- connectTo host (PortNumber (fromIntegral port))
>> hSetBuffering h LineBuffering
>>  cWrite h "GET / HTTP/1.0"
>> cWrite h ""
>> cWaitFor h "ABCD"
>>  con <- contextNewOnHandle h params g
>> handshake con
>> bye con
>>
>>
>> And I get a "BAD request" response from the server - Can some please give
>> me a sample code that uses Network.TLS to connect to a imap.google.com(or 
>> even a webserver for that matter)?
>>
>> Regards,
>> Kashyap
>>
>> ___
>> 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] Type checking the content of a string

2013-02-23 Thread Brent Yorgey
On Fri, Feb 22, 2013 at 06:44:06PM +0100, Corentin Dupont wrote:
> Hi all,
> I have a program able to read another program as a string, and interpret it
> (using Hint).
> I'd like to make unit tests, so I have a file "Test.hs" containing a serie
> of test programs as strings.
> However, how could I be sure that these test program are syntactically
> valid, at compile time?

If you just want to check whether a program is syntactically valid,
you can use the haskell-src-exts package to parse it.  If you also
want to do some type checking you can try the haskell-type-exts
package.

-Brent

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


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread Brandon Allbery
On Sat, Feb 23, 2013 at 1:58 PM, C K Kashyap  wrote:

> What I am really looking for is a small sample code that demonstrates how
> TLS package can be used to connect to a webserver or imapserver.
>

TLS isn't actually SSL, despite SSL getting blessed as "TLS 0.9". Various
attempts at TLS-enabled web protocols have foundered, so you won't find
much code to speak TLS to web servers. (SSL is negotiated at socket connect
time and involves no protocol commands.) In short, sample code that can do
https would be completely useless for comparing to TLS-enabled code.

IMAP is somewhat harder than SMTP; I suggest you read up on the protocol.
I've done a fair amount of work with it, and still would have to refer to
the RFC to establish a connection without the help of an existing IMAP
library.

-- 
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] Need urgent help with Network.tls

2013-02-23 Thread Vincent Hanquez

On 02/23/2013 06:58 PM, C K Kashyap wrote:

The reason I want to use TLS is that I'd want to pack the whole thing in a
DLL and give it off to a friend for use.

What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.

Regards,
Kashyap


Kashyap,

I suggest you look at the connection package [1] which is made for this 
specific purpose, and comes with examples on how to use it [2].


If you want to only use tls, i suggest to look at connection's code [3], 
or the tls-debug [4] package, which got many small utils that use tls.


[1] http://hackage.haskell.org/package/connection
[2] 
https://github.com/vincenthz/hs-connection/tree/master/examples
[3] 
https://github.com/vincenthz/hs-connection/blob/master/Network/Connection.hs

[4] https://github.com/vincenthz/hs-tls/tree/master/debug/src

--
Vincent

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


Re: [Haskell-cafe] Type checking the content of a string

2013-02-23 Thread Corentin Dupont
Finally, I solved the problem using typeOf instead of interpret:

cr :: QuasiQuoter
cr = QuasiQuoter { quoteExp = quoteRuleFunc}

quoteRuleFunc :: String -> Q TH.Exp
quoteRuleFunc s = do
   res <- runIO $ runInterpreter $ do
  setImports ["Prelude", "Language.Nomyx.Expression"]
  typeOf s
   case res of
  Right "RuleFunc" -> [| s |]
  Right _ -> fail $ "Rule doesn't typecheck"
  Left e -> fail $ show e

I don't know really why, but now it's working very well!

On Sat, Feb 23, 2013 at 7:56 PM, Daniel Gorín  wrote:

> Hi Corentin,
>
> I've never used TH, but from what I understand, trying to combine hint and
> TH would be redundant (even if it worked): whatever String you can evaluate
> using hint, you can evaluate it directly in TH. Is this not the case?
>
>  Cheers,
> Daniel
>
> On Feb 23, 2013, at 6:53 PM, Corentin Dupont wrote:
>
> > Hi Daniel,
> > Did you already tried to use Hint in a QuasiQuote? This would come handy
> to check at compile time the validity of some strings...
> > However I have the error hereunder.
> > The duplicate symbol found in the object file is in fact the first
> symbol in this file. So I guess GHCi tries to load it twice...
> > Best,
> > Corentin
> >
> >
> > On Sat, Feb 23, 2013 at 12:03 AM, Corentin Dupont <
> corentin.dup...@gmail.com> wrote:
> > I'm trying to load my interpreter in the Q monad:
> >
> > cr :: QuasiQuoter
> > cr = QuasiQuoter { quoteExp = quoteRuleFunc}
> >
> > quoteRuleFunc :: String -> Q TH.Exp
> > quoteRuleFunc s = do
> >res <- runIO $ runInterpreter $ do
> >   setImports ["Prelude", "Language.Nomyx.Rule",
> "Language.Nomyx.Expression", "Language.Nomyx.Test",
> >"Language.Nomyx.Examples", "GHC.Base", "Data.Maybe"]
> >   interpret s (as :: RuleFunc)
> >case res of
> >   Right _ -> [| s |]
> >   Left e -> fail $ show e
> >
> >
> >  However, I always obtain an error during compilation:
> >
> > ...
> > Loading package XXX ... linking ... done.
> >
> >
> > GHCi runtime linker: fatal error: I found a duplicate definition for
> symbol
> >__stginit_ghczm7zi4zi1_DsMeta
> > whilst processing object file
> >/usr/lib/ghc/ghc-7.4.1/libHSghc-7.4.1.a
> > This could be caused by:
> >* Loading two different object files which export the same symbol
> >* Specifying the same object file twice on the GHCi command line
> >* An incorrect `package.conf' entry, causing some object to be
> >  loaded twice.
> > GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
> >
> >
> > I vaguely understand that the interpreted modules are conflicting with
> the compiled ones...
> >
> >
> >
> > On Fri, Feb 22, 2013 at 11:51 PM, Corentin Dupont <
> corentin.dup...@gmail.com> wrote:
> > Great! That seems very powerful. So you can do what you want during
> compilation, readin files, send data over the network?
> > Other question, in my example how can I halt the compilation if a test
> program is wrong?
> >
> >
> > On Fri, Feb 22, 2013 at 8:30 PM, Francesco Mazzoli  wrote:
> > At Fri, 22 Feb 2013 19:43:51 +0100,
> > Corentin Dupont wrote:
> > > Hi Adam,
> > > that looks interresting. I'm totally new to TH and QuasiQuotes, though.
> > > Can I run IO in a QuasiQuoter? I can run my own interpreter.
> >
> > Yes, you can:
> > <
> http://hackage.haskell.org/packages/archive/template-haskell/2.8.0.0/doc/html/Language-Haskell-TH.html#v:runIO
> >.
> >
> > Francesco
> >
> >
> >
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread Jason Dusek
2013/2/23 C K Kashyap :
> The reason I want to use TLS is that I'd want to pack the whole thing in a
> DLL and give it off to a friend for use.

Why does this requirement compel you to forego the imapget or HaskellNet
packages?

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B

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


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread Vincent Hanquez

On 02/23/2013 09:05 PM, Brandon Allbery wrote:

On Sat, Feb 23, 2013 at 1:58 PM, C K Kashyap  wrote:


What I am really looking for is a small sample code that demonstrates how
TLS package can be used to connect to a webserver or imapserver.


TLS isn't actually SSL, despite SSL getting blessed as "TLS 0.9". Various
attempts at TLS-enabled web protocols have foundered, so you won't find
much code to speak TLS to web servers. (SSL is negotiated at socket connect
time and involves no protocol commands.) In short, sample code that can do
https would be completely useless for comparing to TLS-enabled code.


SSL and TLS can be negociated at socket connect. TLS is just the 
standard name of SSL. at the wire level, TLS1.x is SSL 3.(1+x).


What you're refering to is the STARTTLS style protocol command which 
work independently of the version of TLS (include SSL2, SSL3).


Many programs have abused "SSL" and "TLS" different name to 
differentiate how TLS is negociated (straight away, or with a protocol 
command). Fortunately more and more programs do the right thing and 
differentiate the two types with the following two options: "SSL/TLS" or 
"STARTTLS".


--
Vincent

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


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread Vincent Hanquez

On 02/23/2013 03:28 PM, C K Kashyap wrote:

Hi,

I am trying to use Haskell to download email/attachments from gmail. For
which I am exploring Network.TLS. I got this sample from the net that
connects to gmail smtp and works just fine -
http://hpaste.org/82890

Your example look odd,

Typically you would either:

* connect directly using tls (usually using the standard "secure" 
service port)
* or connect to the normal service port, do a basic handshake with the 
server, tell that you're going to switch the connection with STARTTLS, 
and use tls.


but you will not use both methods in the same connection.

Hope that helps,
--
Vincent

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


[Haskell-cafe] cabal install ghc-mod installs 3 years old version

2013-02-23 Thread Niklas Hambüchen
Hi,

I just did cabal update and cabal install ghc-mod, and for some reason
it tries to install version 0.3.0 from 3 years ago:

"
cabal install ghc-mod -v
Reading available packages...
Choosing modular solver.
Resolving dependencies...
Ready to install ghc-mod-0.3.0
Downloading ghc-mod-0.3.0...
"

cabal --version
cabal-install version 1.16.0.2
using version 1.16.0.3 of the Cabal library


Does anyone have an idea why that could be?

Thanks

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


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
What I am looking to achieve is - create a DLL that would do the complete
gmail thing that could be linked to a standard C program (on windows) and
could be used to download emails from gmail.
What I gathered from HsOpenSSL (which is required for HaskellNet) depends
on some native ssl dll  That is the reason I wanted to get a standalone
library ... again, I might have got the whole thing wrong.

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:54 AM, Jason Dusek  wrote:

> 2013/2/23 C K Kashyap :
> > The reason I want to use TLS is that I'd want to pack the whole thing in
> a
> > DLL and give it off to a friend for use.
>
> Why does this requirement compel you to forego the imapget or HaskellNet
> packages?
>
> --
> Jason Dusek
> pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
Thank you so much Vincent,

I think this is what I need ... I tried to use it to connect to a local web
server running in 443 - http://hpaste.org/82943 however, I get the
following error -

ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))

Am I missing something?

Regards,
Kashyap


On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez  wrote:

> On 02/23/2013 06:58 PM, C K Kashyap wrote:
>
>> The reason I want to use TLS is that I'd want to pack the whole thing in a
>> DLL and give it off to a friend for use.
>>
>> What I am really looking for is a small sample code that demonstrates how
>> TLS package can be used to connect to a webserver or imapserver.
>>
>> Regards,
>> Kashyap
>>
>
> Kashyap,
>
> I suggest you look at the connection package [1] which is made for this
> specific purpose, and comes with examples on how to use it [2].
>
> If you want to only use tls, i suggest to look at connection's code [3],
> or the tls-debug [4] package, which got many small utils that use tls.
>
> [1] 
> http://hackage.haskell.org/**package/connection
> [2] 
> 
> >https://github.**com/vincenthz/hs-connection/**tree/master/examples
> [3] https://github.com/vincenthz/**hs-connection/blob/master/**
> Network/Connection.hs
> [4] 
> https://github.com/vincenthz/**hs-tls/tree/master/debug/src
>
> --
> Vincent
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
Okay ... looks like connection is exactly what I want  The examples
work just fine on Linux .. however, on Windows, I continue to get the
WSACONNECTIONREFUSED eror.

Even adding a "withSocketsDo" does not seem to help.

Regards,
Kashyap


On Sun, Feb 24, 2013 at 8:58 AM, C K Kashyap  wrote:

> Thank you so much Vincent,
>
> I think this is what I need ... I tried to use it to connect to a local
> web server running in 443 - http://hpaste.org/82943 however, I get the
> following error -
>
> ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))
>
> Am I missing something?
>
> Regards,
> Kashyap
>
>
> On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez  wrote:
>
>> On 02/23/2013 06:58 PM, C K Kashyap wrote:
>>
>>> The reason I want to use TLS is that I'd want to pack the whole thing in
>>> a
>>> DLL and give it off to a friend for use.
>>>
>>> What I am really looking for is a small sample code that demonstrates how
>>> TLS package can be used to connect to a webserver or imapserver.
>>>
>>> Regards,
>>> Kashyap
>>>
>>
>> Kashyap,
>>
>> I suggest you look at the connection package [1] which is made for this
>> specific purpose, and comes with examples on how to use it [2].
>>
>> If you want to only use tls, i suggest to look at connection's code [3],
>> or the tls-debug [4] package, which got many small utils that use tls.
>>
>> [1] 
>> http://hackage.haskell.org/**package/connection
>> [2] 
>> 
>> >https://github.**com/vincenthz/hs-connection/**tree/master/examples
>> [3] https://github.com/vincenthz/**hs-connection/blob/master/**
>> Network/Connection.hs
>> [4] 
>> https://github.com/vincenthz/**hs-tls/tree/master/debug/src
>>
>> --
>> Vincent
>>
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Need urgent help with Network.tls

2013-02-23 Thread C K Kashyap
Okay ... now magically, I stopped seeing the "WSACONNECTIONREFUSED"
error!!! ..

Regards,
Kashyap


On Sun, Feb 24, 2013 at 10:03 AM, C K Kashyap  wrote:

> Okay ... looks like connection is exactly what I want  The examples
> work just fine on Linux .. however, on Windows, I continue to get the
> WSACONNECTIONREFUSED eror.
>
> Even adding a "withSocketsDo" does not seem to help.
>
> Regards,
> Kashyap
>
>
> On Sun, Feb 24, 2013 at 8:58 AM, C K Kashyap  wrote:
>
>> Thank you so much Vincent,
>>
>> I think this is what I need ... I tried to use it to connect to a local
>> web server running in 443 - http://hpaste.org/82943 however, I get the
>> following error -
>>
>> ssl_client.hs: connect: failed (Connection refused (WSAECONNREFUSED))
>>
>> Am I missing something?
>>
>> Regards,
>> Kashyap
>>
>>
>> On Sun, Feb 24, 2013 at 3:42 AM, Vincent Hanquez  wrote:
>>
>>> On 02/23/2013 06:58 PM, C K Kashyap wrote:
>>>
 The reason I want to use TLS is that I'd want to pack the whole thing
 in a
 DLL and give it off to a friend for use.

 What I am really looking for is a small sample code that demonstrates
 how
 TLS package can be used to connect to a webserver or imapserver.

 Regards,
 Kashyap

>>>
>>> Kashyap,
>>>
>>> I suggest you look at the connection package [1] which is made for this
>>> specific purpose, and comes with examples on how to use it [2].
>>>
>>> If you want to only use tls, i suggest to look at connection's code [3],
>>> or the tls-debug [4] package, which got many small utils that use tls.
>>>
>>> [1] 
>>> http://hackage.haskell.org/**package/connection
>>> [2] 
>>> 
>>> >https://github.**com/vincenthz/hs-connection/**tree/master/examples
>>> [3] https://github.com/vincenthz/**hs-connection/blob/master/**
>>> Network/Connection.hs
>>> [4] 
>>> https://github.com/vincenthz/**hs-tls/tree/master/debug/src
>>>
>>> --
>>> Vincent
>>>
>>
>>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Fixing undeduceable instance ==> overlapping instance

2013-02-23 Thread Michael Orlitzky
I'm trying to write a determinant function that works on matrices
parameterized by their dimensions (Peano naturals). If I declare the
following,

  -- Define a class so that we get a different determinant function
  -- on the base/recursive cases.
  class (Eq a, Ring.C a) => Determined m a where
determinant :: (m a) -> a

  -- Base case, 1x1 matrices
  instance (Eq a, Ring.C a) => Determined (Mat (S Z) (S Z)) a where
determinant m = m !!! (0,0)

  -- Recursive case, (n+2) x (n+2) matrices.
  instance (Eq a, Ring.C a, Arity n)
 => Determined (Mat (S (S n)) (S (S n))) a where
  determinant m =
...
-- Recursive algorithm, the i,jth minor has dimension
-- (n+1) x (n+1).
foo bar (determinant (minor m i j))

I get an error stating that I'm missing an instance:

  Could not deduce (Determined (Mat (S n) (S n)) a)
  ...

Clearly, I *have* an instance for that case: if n == Z, then it's the
base case. If not, it's the recursive case. But GHC can't figure that
out. So maybe if I define a dummy instance to make it happy, it won't
notice that they overlap?

  instance (Eq a, Ring.C a) => Determined (Mat m m) a where
determinant _ = undefined

No such luck:

  >>> let m = fromList [[1,2],[3,4]] :: Mat2 Int
  >>> determinant m

Overlapping instances for Determined (Mat N2 N2) Int
  arising from a use of `determinant'
Matching instances:
  instance (Eq a, Ring.C a) => Determined (Mat m m) a
-- Defined at Linear/Matrix2.hs:353:10
  instance (Eq a, Ring.C a, Arity n) =>
   Determined (Mat (S (S n)) (S (S n))) a
...

I even tried generalizing the (Mat m m) instance definition so that
OverlappingInstances would pick the one I want, but I can't get that to
work either.

Is there some way to massage this?

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


Re: [Haskell-cafe] Fixing undeduceable instance ==> overlapping instance

2013-02-23 Thread Karl Voelker
On Sat, Feb 23, 2013 at 10:28 PM, Michael Orlitzky wrote:

>   -- Recursive case, (n+2) x (n+2) matrices.
>   instance (Eq a, Ring.C a, Arity n)
>  => Determined (Mat (S (S n)) (S (S n))) a where
>   determinant m =
> ...
> -- Recursive algorithm, the i,jth minor has dimension
> -- (n+1) x (n+1).
> foo bar (determinant (minor m i j))
>
> I get an error stating that I'm missing an instance:
>
>   Could not deduce (Determined (Mat (S n) (S n)) a)
>   ...
>

It looks to me like you just need to add (Determined (Mat (S n) (S n)) a)
into the context of this instance. The problem is that the type variable
"n" could be almost anything (at least as far as this instance definition
knows).

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


Re: [Haskell-cafe] cabal install ghc-mod installs 3 years old version

2013-02-23 Thread Ivan Lazar Miljenovic
On 24 February 2013 12:38, Niklas Hambüchen  wrote:
> Hi,
>
> I just did cabal update and cabal install ghc-mod, and for some reason
> it tries to install version 0.3.0 from 3 years ago:
>
> "
> cabal install ghc-mod -v
> Reading available packages...
> Choosing modular solver.
> Resolving dependencies...
> Ready to install ghc-mod-0.3.0
> Downloading ghc-mod-0.3.0...
> "
>
> cabal --version
> cabal-install version 1.16.0.2
> using version 1.16.0.3 of the Cabal library
>
>
> Does anyone have an idea why that could be?

Which version of GHC (and hence base, etc.)? My guess is that for some
reason it thinks that some requirement of the later versions is
incompatible with your version of GHC.

Maybe explicitly try " cabal install 'ghc-mod >= 1.11.4' " and see why
it doesn't like it.

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



-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
http://IvanMiljenovic.wordpress.com

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


Re: [Haskell-cafe] Fixing undeduceable instance ==> overlapping instance

2013-02-23 Thread Michael Orlitzky
On 02/24/2013 02:14 AM, Karl Voelker wrote:
> On Sat, Feb 23, 2013 at 10:28 PM, Michael Orlitzky  > wrote:
> 
>   -- Recursive case, (n+2) x (n+2) matrices.
>   instance (Eq a, Ring.C a, Arity n)
>  => Determined (Mat (S (S n)) (S (S n))) a where
>   determinant m =
> ...
> -- Recursive algorithm, the i,jth minor has dimension
> -- (n+1) x (n+1).
> foo bar (determinant (minor m i j))
> 
> I get an error stating that I'm missing an instance:
> 
>   Could not deduce (Determined (Mat (S n) (S n)) a)
>   ...
> 
> 
> It looks to me like you just need to add (Determined (Mat (S n) (S n))
> a) into the context of this instance. The problem is that the type
> variable "n" could be almost anything (at least as far as this instance
> definition knows).
> 

So simple, thank you!


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