Dear List,
I've been stumped for a few months on the following example, from
chapter 13 of LYH
http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions
runState (join (State $ \s -> (push 10,1:2:s))) [0,0,0]
I find the following implementation of join in the text is hard to
understand or apply
join :: (Monad m) => m (m a) -> m a
join mm = do
m <- mm
m
In contrast, I find the following definition(?) on Haskell Wikibooks
https://en.wikibooks.org/wiki/Haskell/Category_theory#Monads
join :: Monad m => m (m a) -> m a
join x = x >>= id
easier to understand, and although I can apply it to the following
Writer Monad example, in the same section of LYH,
runWriter $ join (Writer (Writer (1,"aaa"),"bbb"))
I cannot apply it to the State Monad example.
Regards,
- Olumide
Hello, I try to reproduce this kind of python code into haskell
--- python -- whcih use the suds module
cj = CookieJar()
url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
transport = HttpAuthenticated(username=self.getIspybUserName(),
password=self.getIspybPassWord())
service_name = "ToolsForCollectionWebService"
url = "http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl"
collectionWSClient = Client(url, transport=transport, timeout=3)
collect_params = collectionWSClient.service.findDataCollection(dataCollectionId)---
---
Has you can see, I create a Transport whcih need an Authentification and also I need to use a cookieJar in oder to manage the connection.
The a soap client is instanciated from the url and with this transport.
Then the findDatacollection service is called.
Now I would like to reproduce this with Haskell and the soap package (or not if it is easier without)
I started like this
getDataCollection :: Transport -> Int -> IO Response
getDataCollection t i = invokeWS t url () body parser
where
url = "http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl" -- ?wsdl/findDatacollection"
body = elementA "ToolsForCollectionWebService" [("xmlns", "findDataCollection")]
$ element "dataCollectionID" i
parser = StreamParser
. flaxTag ""
$ response
response = Response
<$> flaxContent "filePath"
main :: IO ()
main = do
-- Initial one-time preparations.
transport <- initTransportWithM defaultManagerSettings url pure pure
response <- getDataCollection transport dataCollectionID
print response
And When I run this I have this message
autoprocessing-exe: HttpExceptionRequest Request {
host = "xxx.xxx.xxx.xxx"
port = 80
secure = False
requestHeaders = [("Content-Type","text/xml; charset=utf-8"),("SOAPAction","http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl")]
path = "/ispyb-ws/ispybWS/ToolsForCollectionWebService"
queryString = ""
method = "POST"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutMicro 15000000
requestVersion = HTTP/1.1
}
TlsNotSupported
I know that I do not want the https, the url is http and not https.
now I do not know how to modify this in order to deal with the authentification and the cookiesJar.
It seems here that proxy is Nothing so I hope thqht it will use the http[s]_proxy environment variable.
thanks for your help.
Frederic
In the Haskell litrature desugaring of type clases to a data type is
mentioned.
For example:
class Foo a where
quux :: a -> Int
muux :: a -> Bool
Desugared to
data FooD a = FooD -- class Foo a where
{ quuxD :: a -> Int -- quux :: a -> Int
, muuxD :: a -> Bool -- muux :: a -> Bool
}
Is there any way using core dumps to actuall view the desugring of classes,
sub-classes, and instances, in my own code?
I have tried:
ghc -c -ddump-ds Foo.hs
But I cannot understand the output.
Thanks,
Pat
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa
ríomhphost nó sna hiatáin seo. www.dit.ie
Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>