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: How to correctly define data types? (Davi Santos)
2. Re: How to correctly define data types? (Brent Yorgey)
3. Re: How to correctly define data types? (Davi Santos)
4. Re: Combining GHC library and Platform documentation
(Mister Globules)
----------------------------------------------------------------------
Message: 1
Date: Tue, 19 Jul 2011 13:46:19 -0300
From: Davi Santos <[email protected]>
Subject: Re: [Haskell-beginners] How to correctly define data types?
To: [email protected]
Message-ID:
<canwsst8wnfns+40yanw7tv+fmcidk+qgh3uhh95jhuwhpm1...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Brent, thanks for answering.
Sorry, by "set" I meant "access" [the field "attributes"]. But you already
answered, it depends on the ML module implementation choice.
One more question about elegance:
How to make Examples "sortable" by distance to a reference point
"referenceEx"?
For instance, if referenceEx was not needed:
-----------------------------
listExs = [Example {att=[2,5,3]}, Example {att=[0,2,3]}, Example
{att=[2,0,9]}]
sortedExamples =
sort listExs
==================
With referenceEx, I tried this, but it is getting ugly:
------------------------------
sortedExamples =
sort $ map (ExamplesPair referenceEx) listExs
================
------ML.hs------------------------------------------
data ExamplesPairClass =
ExamplesPair {ex1 :: Example, ex2 :: Example} deriving (Show, Eq)
instance Ord ExamplesPairClass where
(ExamplesPair ex1 referenceEx) ? (ExamplesPair ex2 referenceEx) =
(ex1 distance referenceEx) ? (ex2 distance referenceEx)
==================================
Sorry that amount of code, it is terrible to read with no colorizing.
Davi
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110719/02d7c384/attachment-0001.htm>
------------------------------
Message: 2
Date: Tue, 19 Jul 2011 15:50:41 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] How to correctly define data types?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Tue, Jul 19, 2011 at 01:46:19PM -0300, Davi Santos wrote:
> Brent, thanks for answering.
> Sorry, by "set" I meant "access" [the field "attributes"]. But you already
> answered, it depends on the ML module implementation choice.
>
> One more question about elegance:
> How to make Examples "sortable" by distance to a reference point
> "referenceEx"?
To sort by distance to a given reference point you could use something
like
import Data.List (sortBy)
import Data.Ord (comparing)
...
sortedExamples = sortBy (comparing (distance referenceEx)) listExs
-Brent
------------------------------
Message: 3
Date: Tue, 19 Jul 2011 18:41:28 -0300
From: Davi Santos <[email protected]>
Subject: Re: [Haskell-beginners] How to correctly define data types?
To: [email protected]
Message-ID:
<CANWsST-5gurFzt7OY78DU79+kuUffxjpgNGmdnU=xxkksab...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Ok, it seems a better.
thanks
Davi
To sort by distance to a given reference point you could use something
like
import Data.List (sortBy)
import Data.Ord (comparing)
...
sortedExamples = sortBy (comparing (distance referenceEx)) listExs
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110719/f08a75ce/attachment-0001.htm>
------------------------------
Message: 4
Date: Wed, 20 Jul 2011 06:36:46 +0000 (UTC)
From: Mister Globules <[email protected]>
Subject: Re: [Haskell-beginners] Combining GHC library and Platform
documentation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Magnus Therning <magnus <at> therning.org> writes:
>
> On Tue, Jul 19, 2011 at 05:51:31AM +0000, Mister Globules wrote:
> > [...]
> > Is there a simple way to create one index.html file with links to all the
> > documentation?
> >
> > As a bonus, is it possible to do the same thing with libraries that I
> > install with cabal?
> >
> > - Globules
> > [...]
>
> Hopefully you have a script installed, as part of ghc itself, called
> gen_contents_index. It's what we in Arch use to update the index.html
> file when installing/removing Haskell packages. I'm not sure it
> already supports privately installed packages, but hopefully it won't
> be too difficult to modify.
>
> /M
>
Thanks Magnus, I found the script. Based on its behaviour in the no-args
case (I didn't look too closely at --inplace) I wrote a similar script that
allows me to specify multiple directories on the command-line. So, I can
specify the GHC, platform and my personal libraries.
In case anyone finds it useful I've appended it below. (Hopefully, it will
make it through relatively unscathed.)
- Globules
The following script is in the public domain.
#!/bin/sh -eu
#
# Generate HTML contents and an index for Haskell libraries.
#
# WARNING: May not handle whitespace, etc. in paths.
#
# Run this command from the directory in which you want index.html created. The
# package directory arguments can be relative or absolute paths.
#
# Usage:
#
# mkhaskellhtml pkg_dir ...
#
# Example - GHC and platform docs:
#
# cd /local/pkg/ghc-7.0.3/share/doc/ghc/html/libraries
# mkhaskellhtml . /local/pkg/haskell-platform-2011.2.0.1/share/doc
#
# Example - GHC, platform and user package docs:
#
# cd /local/pkg/ghc-7.0.3/share/doc/ghc/html/libraries
# mkhaskellhtml . /local/pkg/haskell-platform-2011.2.0.1/share/doc
~/.cabal/share/doc
#
# The default GHC home directory, if the GHC_HOME variable is not set.
GHC_DFL=/local/pkg/ghc-7.0.3
# Exclude the GHC API. If you want the GHC API use cat instead.
filter_ghc_api () {
grep -v 'ghc\.haddock$'
# cat
}
PATH=${GHC_HOME:-$GHC_DFL}/bin:/bin:/usr/bin
if [ $# -lt 1 ]; then
echo Too few arguments. 1>&2
echo Usage: $(basename $0) pkg_dir ... 1>&2
exit 1
fi
ris=$(find "$@" -type f -name \*.haddock |
filter_ghc_api |
while read hdk ; do
echo --read-interface=${hdk%/*.haddock},$hdk
done)
[ -z "$ris" ] && { echo 'No packages found!'; exit 0; }
haddock \
--gen-index \
--gen-contents \
-o . \
-t "Haskell Hierarchical Libraries" \
-p prologue.txt \
$ris
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 37, Issue 37
*****************************************