Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  grouping functions together (Dimitri DeFigueiredo)
   2. Re:  grouping functions together (Rein Henrichs)
   3. Re:  Usage of $ (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   4.  (no subject) (steve barak)
   5. Re:  cabal install glfw failing
      (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   6. Re:  (no subject) (Sumit Sahrawat, Maths & Computing, IIT (BHU))


----------------------------------------------------------------------

Message: 1
Date: Mon, 08 Jun 2015 15:47:00 -0600
From: Dimitri DeFigueiredo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] grouping functions together
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hello!

I am trying to tie together a group of functions that turn an unreliable 
remote network call into a reliable one. For each different network 
request I make, a specific group of these functions should always work 
together, but their type signatures are quite different. My first 
thought was to put them all in a typeclass:

import Control.Monad

class Reliable1 m req attempt ack failure result where
     getRequests1 :: Monad m =>               m [req]
     mkAttempt1   :: Monad m => req        -> m (Maybe attempt)
     action1      :: Monad m => attempt    -> m (Maybe ack)
     getAcks1     :: Monad m => [attempt]  -> m [ack]
     mkResult1    :: Monad m => req -> ack -> m (Either failure result)
     run1         :: Monad m => req        -> m result

That doesn't work because not all functions use all parameters. For 
example, getAcks1 has no idea of what the final 'result' type parameter 
is. This lead me to my second attempt. Defining a 'service' type with 
the sole purpose of tying them all together. Here's my current attempt:

{-# LANGUAGE MultiParamTypeClasses #-}

import Control.Monad

class Reliable m service where
     getReqs     :: Monad m => service ->               m [req]
     mkAttempt   :: Monad m => service -> req        -> m (Maybe attempt)
     action      :: Monad m => service -> attempt    -> m (Maybe ack)
     getAcks     :: Monad m => service -> [attempt]  -> m [ack]
     mkResult    :: Monad m => service -> req -> ack -> m (Either 
failure result)
     run         :: Monad m => service -> req        -> m result

data RemoteCall = RemoteCall

instance Reliable IO RemoteCall where
     getReqs     = undefined
     mkAttempt   = undefined
     action      = undefined
     getAcks     = undefined
     mkResult    = undefined
     run         = undefined

This works, but I have to explicitly pass the 'service' argument in 
every call.
Can I avoid passing this parameter every time?
Question, is there a better way to do this?
I wanted to have a wrapper to make my remote calls reliable.

Thanks,

Dimitri





------------------------------

Message: 2
Date: Mon, 08 Jun 2015 22:36:27 +0000
From: Rein Henrichs <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] grouping functions together
Message-ID:
        <CAJp6G8zoJnW9fm56R9c=wj6ivsjqpwnptpeijgcdt601ese...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

This seems like a case where you only really need a record, not a typeclass.

On Mon, Jun 8, 2015 at 2:47 PM Dimitri DeFigueiredo <
[email protected]> wrote:

> Hello!
>
> I am trying to tie together a group of functions that turn an unreliable
> remote network call into a reliable one. For each different network
> request I make, a specific group of these functions should always work
> together, but their type signatures are quite different. My first
> thought was to put them all in a typeclass:
>
> import Control.Monad
>
> class Reliable1 m req attempt ack failure result where
>      getRequests1 :: Monad m =>               m [req]
>      mkAttempt1   :: Monad m => req        -> m (Maybe attempt)
>      action1      :: Monad m => attempt    -> m (Maybe ack)
>      getAcks1     :: Monad m => [attempt]  -> m [ack]
>      mkResult1    :: Monad m => req -> ack -> m (Either failure result)
>      run1         :: Monad m => req        -> m result
>
> That doesn't work because not all functions use all parameters. For
> example, getAcks1 has no idea of what the final 'result' type parameter
> is. This lead me to my second attempt. Defining a 'service' type with
> the sole purpose of tying them all together. Here's my current attempt:
>
> {-# LANGUAGE MultiParamTypeClasses #-}
>
> import Control.Monad
>
> class Reliable m service where
>      getReqs     :: Monad m => service ->               m [req]
>      mkAttempt   :: Monad m => service -> req        -> m (Maybe attempt)
>      action      :: Monad m => service -> attempt    -> m (Maybe ack)
>      getAcks     :: Monad m => service -> [attempt]  -> m [ack]
>      mkResult    :: Monad m => service -> req -> ack -> m (Either
> failure result)
>      run         :: Monad m => service -> req        -> m result
>
> data RemoteCall = RemoteCall
>
> instance Reliable IO RemoteCall where
>      getReqs     = undefined
>      mkAttempt   = undefined
>      action      = undefined
>      getAcks     = undefined
>      mkResult    = undefined
>      run         = undefined
>
> This works, but I have to explicitly pass the 'service' argument in
> every call.
> Can I avoid passing this parameter every time?
> Question, is there a better way to do this?
> I wanted to have a wrapper to make my remote calls reliable.
>
> Thanks,
>
> Dimitri
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150608/6cf3e790/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 9 Jun 2015 07:15:31 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Usage of $
Message-ID:
        <cajbew8ou2l7hf6a2f58m61b0mpfa+miuz2pqwvrvww4cfv9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

> s mp $ n - 1 parses as s mp (n - 1)
> s mp n - 1 parses as (s mp n) - 1

It should be

s mp $ n - 1 parses as ($) (s mp) (n - 1) which evaluates to s mp (n - 1)
The parsing goes this way because ($) has the lowers precedence.

-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150609/d9fabf40/attachment-0001.html>

------------------------------

Message: 4
Date: Mon, 8 Jun 2015 18:56:46 -0700
From: steve barak <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] (no subject)
Message-ID:
        <CAGPKgg8WfJnYR=szc+jy5uv6sjonxb8x0x8-ujvxbdorar0...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Unsuscribe me from this list

Steve Barak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150608/cb83f3be/attachment-0001.html>

------------------------------

Message: 5
Date: Tue, 9 Jun 2015 07:27:19 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] cabal install glfw failing
Message-ID:
        <cajbew8mycgxcaaviyhp8bn5sgb+ara2qkf6cpdsk2e-d1wx...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

It seems like the gflw package doesn't support ghc 7.10 yet. Try
downgrading to 7.8.4 and it should work.

On 8 June 2015 at 18:01, Martin Vlk <[email protected]> wrote:

> Hi, I am trying to install the Euterpea library, which depends on glfw,
> but it is failing to install with a compilation failure.
>
> Could someone take a look at the error and tell me what might be wrong?
>
> Many Thanks
> Martin
>
> The Glorious Glasgow Haskell Compilation System, version 7.10.1
> cabal-install version 1.22.4.0
> using version 1.22.3.0 of the Cabal library
>
> $ cabal update
> $ cabal install glfw
>
> Resolving dependencies...
> Configuring GLFW-0.5.2.2...
> Failed to install GLFW-0.5.2.2
> Build log ( /home/martin/.cabal/logs/GLFW-0.5.2.2.log ):
> cabal: Error: some packages failed to install:
> GLFW-0.5.2.2 failed during the configure step. The exception was:
> user error ('/home/martin/.ghc/bin/ghc' exited with an error:
>
> /tmp/GLFW-0.5.2.2-20349/GLFW-0.5.2.2/dist/setup/setup.hs:106:14:
> No instance for (Applicative (StateT ConfState IO))
> arising from a use of ?modify?
> In the expression: modify
> In the expression:
> modify $ \ (ConfState fs ls) -> ConfState fs (lib : ls)
> In an equation for ?addLib?:
> addLib lib
> = modify $ \ (ConfState fs ls) -> ConfState fs (lib : ls)
>
> /tmp/GLFW-0.5.2.2-20349/GLFW-0.5.2.2/dist/setup/setup.hs:242:10:
> Could not deduce (Applicative (StateT s m))
> arising from the superclasses of an instance declaration
> from the context (Monad m)
> bound by the instance declaration
> at /tmp/GLFW-0.5.2.2-20349/GLFW-0.5.2.2/dist/setup/setup.hs:242:10-40
> In the instance declaration for ?Monad (StateT s m)?
>
> /tmp/GLFW-0.5.2.2-20349/GLFW-0.5.2.2/dist/setup/setup.hs:252:10:
> Could not deduce (Applicative (StateT s m))
> arising from the superclasses of an instance declaration
> from the context (Monad m)
> bound by the instance declaration
> at /tmp/GLFW-0.5.2.2-20349/GLFW-0.5.2.2/dist/setup/setup.hs:252:10-47
> In the instance declaration for ?MonadState s (StateT s m)?
> )
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150609/325b7ee8/attachment-0001.html>

------------------------------

Message: 6
Date: Tue, 9 Jun 2015 07:28:18 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] (no subject)
Message-ID:
        <CAJbEW8NLgJtTA8PPXqPSLUhZQ_4t-SEcPQHd0O=9gQV0k=e...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

On 9 June 2015 at 07:26, steve barak <[email protected]> wrote:

> Unsuscribe me from this list
>
> Steve Barak
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20150609/ee7d617e/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 84, Issue 14
*****************************************

Reply via email to