Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/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. Re:  arrow type signature question (MH)
   2. Re:  arrow type signature question (Daniel Fischer)
   3. Re:  arrow type signature question (MH)
   4. Re:  arrow type signature question (Daniel Fischer)
   5.  Package Documentation (Haddock) (Bastian Erdn??)
   6. Re:  Package Documentation (Haddock) (Daniel Fischer)
   7. Re:  Package Documentation (Haddock) (Bastian Erdn??)


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

Message: 1
Date: Thu, 18 Nov 2010 12:51:32 -0500
From: MH <[email protected]>
Subject: Re: [Haskell-beginners] arrow type signature question
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Oh, so this signature is really a partial application that expects another
parameter to be executed.
So
resultFun   :: (h b -> h b') -> (h (a->b) -> h (a->b'))
is
foo :: h b -> h b'
bar :: h (a->b) -> h (a->b')

firstFunction = resultFun foo
result = firstFunction bar

Is this correct?

On Thu, Nov 18, 2010 at 10:52 AM, Daniel Fischer
<[email protected]>wrote:

> On Thursday 18 November 2010 16:07:34, MH wrote:
> > I am looking at signatures for Arrow and Composable classes and I cannot
> > understand some of them. Could you please explain me the following:
> > Let's take for example the following:
> >
> > class FunAble h => FunDble h where
> >   resultFun   :: (h b -> h b') -> (h (a->b) -> h (a->b'))
> >
> > class FunAble h where
> >   secondFun :: (h b -> h b') -> (h (a,b) -> h (a,b')) -- for 'second'
> >
> >
> > in the signatures:
> > resultFun   :: (h b -> h b') -> (h (a->b) -> h (a->b'))
> > secondFun :: (h b -> h b') -> (h (a,b) -> h (a,b'))
> >
> > if (h b -> h b') is the input of these functions where does 'a' comes
> > from in the output?
>
> 'a' is arbitrary, so it works for all 'a'. The result of resultFun foo,
> resp. secondFun foo is a function of type
>
> h (a -> b) -> h (a -> b')
>
> resp.
>
> h (a,b) -> h (a,b')
>
> where the types b and b' have been determined by foo (not necessarily
> completely, if foo is id, all that has been determined is that b' = b) and
> 'a' is still arbitrary. The type variable 'a' is fixed or restricted when
> xxxFun gets its second argument, bar in
>
> resultFun foo bar
>
> resp.
>
> secondFun foo bar.
>
> >
> > Thanks,
>
> HTH,
> Daniel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101118/bebeb951/attachment-0001.html

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

Message: 2
Date: Thu, 18 Nov 2010 19:29:32 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] arrow type signature question
To: MH <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

On Thursday 18 November 2010 18:51:32, MH wrote:
> Oh, so this signature is really a partial application that expects
> another parameter to be executed.

Depends on how you look at it.
Strictly speaking, there is no such thing as partial application. Every 
function takes exactly one argument, so it's either not applied to any 
argument at all yet or it's fully applied. But the result of a function 
application can be another function, so it may take another argument ...

However, always talking about functions taking an argument of type a and 
returning a function taking an argument of type b and returning a function 
taking an argument of type c ...
is terribly cumbersome, so we speak of functions taking several arguments.

But note that the number of arguments a function takes until the final 
result is no longer a function is not always fixed. For example,
id :: a -> a takes one argument, obviously, doesn't it?
But if that argument is a function, it takes one more argument, so id can 
take two arguments, or three, or however many you want, it depends on which 
arguments you pass.

So when you have a value of type a -> b -> c (which is the same as
a -> (b -> c), since the function arrow is right-associative), and apply it 
to a value of type a, sometimes it is more appropriate to think of that as 
a partial application, sometimes as a complete application resulting in a 
function.

> So
> resultFun   :: (h b -> h b') -> (h (a->b) -> h (a->b'))

which is

resultFun :: (h b -> h b') -> h (a -> b) -> h (a -> b')

> is
> foo :: h b -> h b'

Yes

> bar :: h (a->b) -> h (a->b')

No. bar :: h (a -> b)

resultFun foo :: h (a -> b) -> h (a -> b')

so it takes an argument of type h (a -> b) and its result has type
h (a -> b')
(which may be another function type, if h x = e -> x).

>
> firstFunction = resultFun foo
> result = firstFunction bar

Yep

>
> Is this correct?


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

Message: 3
Date: Thu, 18 Nov 2010 13:43:43 -0500
From: MH <[email protected]>
Subject: Re: [Haskell-beginners] arrow type signature question
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I got it. Thanks a lot. By the way, can you provide with example of using
resultFun or secondFun.
I did search on Hyahoo and Hoogle for names and signatures and I didn't see
any.

Thanks,

Malik

On Thu, Nov 18, 2010 at 1:29 PM, Daniel Fischer <[email protected]>wrote:

> On Thursday 18 November 2010 18:51:32, MH wrote:
> > Oh, so this signature is really a partial application that expects
> > another parameter to be executed.
>
> Depends on how you look at it.
> Strictly speaking, there is no such thing as partial application. Every
> function takes exactly one argument, so it's either not applied to any
> argument at all yet or it's fully applied. But the result of a function
> application can be another function, so it may take another argument ...
>
> However, always talking about functions taking an argument of type a and
> returning a function taking an argument of type b and returning a function
> taking an argument of type c ...
> is terribly cumbersome, so we speak of functions taking several arguments.
>
> But note that the number of arguments a function takes until the final
> result is no longer a function is not always fixed. For example,
> id :: a -> a takes one argument, obviously, doesn't it?
> But if that argument is a function, it takes one more argument, so id can
> take two arguments, or three, or however many you want, it depends on which
> arguments you pass.
>
> So when you have a value of type a -> b -> c (which is the same as
> a -> (b -> c), since the function arrow is right-associative), and apply it
> to a value of type a, sometimes it is more appropriate to think of that as
> a partial application, sometimes as a complete application resulting in a
> function.
>
> > So
> > resultFun   :: (h b -> h b') -> (h (a->b) -> h (a->b'))
>
> which is
>
> resultFun :: (h b -> h b') -> h (a -> b) -> h (a -> b')
>
> > is
> > foo :: h b -> h b'
>
> Yes
>
> > bar :: h (a->b) -> h (a->b')
>
> No. bar :: h (a -> b)
>
> resultFun foo :: h (a -> b) -> h (a -> b')
>
> so it takes an argument of type h (a -> b) and its result has type
> h (a -> b')
> (which may be another function type, if h x = e -> x).
>
> >
> > firstFunction = resultFun foo
> > result = firstFunction bar
>
> Yep
>
> >
> > Is this correct?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20101118/24395fbf/attachment-0001.html

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

Message: 4
Date: Thu, 18 Nov 2010 20:05:56 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] arrow type signature question
To: MH <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="utf-8"

On Thursday 18 November 2010 19:43:43, MH wrote:
> I got it.

Great.

> Thanks a lot.

'twas a pleasure.

> By the way, can you provide with example of using resultFun or secondFun.

No, sorry, I've never used them myself nor came across code using them.

> I did search on Hyahoo and Hoogle for names and signatures and I didn't
> see any.
>
> Thanks,
>
> Malik



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

Message: 5
Date: Thu, 18 Nov 2010 20:25:26 +0100
From: Bastian Erdn?? <[email protected]>
Subject: [Haskell-beginners] Package Documentation (Haddock)
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi,

I found the Haddock documentation to the packages that came with the Haskell 
Platform locally on my machine.

1) It's a little bit uncomfortable to always pick the right one by hand.  Is 
there a more comfortable way like doing e.g. 'haddock Data.List' (that's not 
working) to direct to the documentation of a certain module?

2) I cannot find the documentation to the packages I post installed with cabal. 
 I tried to build them using e.g. 'cabal haddock Yampa' but that's not working. 
 How do I do it right?

Thanks for your help in advance,
Bastian

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

Message: 6
Date: Thu, 18 Nov 2010 20:46:59 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Package Documentation (Haddock)
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

On Thursday 18 November 2010 20:25:26, Bastian Erdnüß wrote:
> Hi,
>
> I found the Haddock documentation to the packages that came with the
> Haskell Platform locally on my machine.
>
> 1) It's a little bit uncomfortable to always pick the right one by hand.
>  Is there a more comfortable way like doing e.g. 'haddock Data.List'
> (that's not working) to direct to the documentation of a certain module?

Sorry, I don't understand what you want.
To view the haddocks, there's an index.html in the docdir, bookmark that in 
your browser and click from there.
If you want to generate haddocks for your project(s) and have it link to 
the modules you used, the simplest way is to create a .cabal file and let 
cabal take care of directing haddock to the installed docs (you can do it 
manually with --read-interface flags, but letting cabal figure out the 
correct flags is easier).

>
> 2) I cannot find the documentation to the packages I post installed with
> cabal.  I tried to build them using e.g. 'cabal haddock Yampa' but
> that's not working.  How do I do it right?

Edit your ~/.cabal/config, set

documentation: True

there, then cabal builds docs for all packages it installs automatically 
(and creates a comprehensive index in ~/.cabal/share/doc). Unfortunately, 
it doesn't build docs for packages it previously installed, so you'd have 
to reinstall them or create the haddocks manually [the latter may need 
unpacking the packages]. If you haven't installed many packages yet, 
reinstalling is probably the simpler route.

>
> Thanks for your help in advance,
> Bastian


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

Message: 7
Date: Thu, 18 Nov 2010 21:20:45 +0100
From: Bastian Erdn?? <[email protected]>
Subject: Re: [Haskell-beginners] Package Documentation (Haddock)
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1


On Nov 18, 2010, at 20:46, Daniel Fischer wrote:

> On Thursday 18 November 2010 20:25:26, Bastian Erdnüß wrote:
>> Hi,
>> 
>> I found the Haddock documentation to the packages that came with the
>> Haskell Platform locally on my machine.
>> 
>> 1) It's a little bit uncomfortable to always pick the right one by hand.
>> Is there a more comfortable way like doing e.g. 'haddock Data.List'
>> (that's not working) to direct to the documentation of a certain module?
> 
> Sorry, I don't understand what you want.

No matter.  Maybe me not either.

> To view the haddocks, there's an index.html in the docdir, bookmark that in 
> your browser and click from there.

That works for the Modules that came with GHC but not for the others in the 
Haskell Platform.  (On the Mac with the Haskell Platform there came the 
GHC.framework and the HaskellPlatform.framework.  In the doc folder of the 
GHC.framework is a central index.html in the doc folder of the HaskellPlatform, 
it isn't.)  However, still an improvement.

> If you want to generate haddocks for your project(s) and have it link to 
> the modules you used, the simplest way is to create a .cabal file and let 
> cabal take care of directing haddock to the installed docs (you can do it 
> manually with --read-interface flags, but letting cabal figure out the 
> correct flags is easier).

I'm not that far yet with Haskell.  But I mark that note for later.

>> 2) I cannot find the documentation to the packages I post installed with
>> cabal.  I tried to build them using e.g. 'cabal haddock Yampa' but
>> that's not working.  How do I do it right?
> 
> Edit your ~/.cabal/config, set
> 
> documentation: True

I just did.

> there, then cabal builds docs for all packages it installs automatically 
> (and creates a comprehensive index in ~/.cabal/share/doc). Unfortunately, 
> it doesn't build docs for packages it previously installed, so you'd have 
> to reinstall them or create the haddocks manually [the latter may need 
> unpacking the packages]. If you haven't installed many packages yet, 
> reinstalling is probably the simpler route.

Well, there are to much to reinstall everyone per hand, but not to much if 
there is a magic command like 'cabal upgrade --reinstall --all' to do it all at 
once.  Any help how to do that?

>> Thanks for your help in advance,
>> Bastian

^^ still valid

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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 29, Issue 26
*****************************************

Reply via email to