[Haskell-cafe] Re: Windows details

2008-09-13 Thread Jeff Zaroyko
Andrew Coppin andrewcoppin at btinternet.com writes:

 
 Jeff Zaroyko wrote:
  Andrew Coppin andrewcoppin at btinternet.com writes:
 

  Jeff Zaroyko wrote:
  
  In theory, you should be able to use mingw's windres tool to produce
  an object file from the resource definition which you'd link with 
  the rest of your program.
 
 I literally cannot *believe* how hard it is to put a few little words 
 into that version tab... Every other kind of resource seems to be 
 completely trivial, but this just won't work for toffee!
 

I'm sure you'll work something out, my test worked, I used a .res file I had
lying around from Wine's ddraw.dll, used windres ddraw.res -o version.o to make
an object file then using ghc hello.hs version.o linked it against hello world.

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


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Max Bolingbroke
2008/9/12 Andrew Coppin [EMAIL PROTECTED]:
 Any ideas about the build log error that's preventing Hackage from
 autogenerating the documentation?

That is a Cabal problem: Duncan Coutts tells me that it is fixed in
HEAD, so documentation will be available on Hackage when they update
the version of Cabal they are using.

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


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Max Bolingbroke
2008/9/13 Brandon S. Allbery KF8NH [EMAIL PROTECTED]:
 Right. Unless you send an ^[^H]0;foo^G sequence (^[ being ESC) to your
 xterm. You'll find that the title changes to foo.


 0 = both title and icon
 1 = icon name
 2 = titlebar text

 Most X11 terminal emulators use the same protocol.  (ISTR that dtterm
 doesn't, but I don't think most people care any more.)  One other gotcha is
 that Terminal.app on Leopard (dunno about Tiger) treats 0, 1, 2 the same way
 so if you set the icon name after the title you end up with the icon name in
 the titlebar.  (OSX uses the titlebar text as the icon name when minimized.)

Interesting information. I'll look into adding this to my package then: cheers!

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


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Max Bolingbroke
2008/9/13 Max Bolingbroke [EMAIL PROTECTED]:
 Interesting information. I'll look into adding this to my package then: 
 cheers!

Just FYI, I have now implemented and tested this feature. The new
version, 0.5.0, is available on Hackage.

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


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Andrew Coppin

Max Bolingbroke wrote:

2008/9/13 Max Bolingbroke [EMAIL PROTECTED]:
  

Interesting information. I'll look into adding this to my package then: cheers!



Just FYI, I have now implemented and tested this feature. The new
version, 0.5.0, is available on Hackage.
  


For both platforms?

Out of interest, how do you get the correct package built on each platform?

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


Re: [Haskell-cafe] Erroneous package listings in hackage?

2008-09-13 Thread Dougal Stanton
On Sat, Sep 13, 2008 at 1:51 AM, Duncan Coutts
[EMAIL PROTECTED] wrote:
 Perhaps for packages that are installed but not re-installable via Cabal
 (like cairo, base, ghc etc) it should say something. Do you have any
 specific suggestions?

Well that explains it then! I had no idea it listed stuff not
available from Hackage. I've been using `cabal list | grep foo` to
search for packages but that's obviously not optimal, it seems.

I don't know what would clarify the matter. An available from
Hackage: (yes/no) field? Or a flag to pass to `cabal list` to show
Hackage stuff only?

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Max Bolingbroke
2008/9/13 Andrew Coppin [EMAIL PROTECTED]:
 Just FYI, I have now implemented and tested this feature. The new
 version, 0.5.0, is available on Hackage.

 For both platforms?

Of course! My package promises to work cross-platform, after all.

 Out of interest, how do you get the correct package built on each platform?

If you mean how do I compile the ANSI emulator on Windows but the
actual ANSI stuff on Unix, most of the magic is in the .cabal file:
http://github.com/batterseapower/ansi-terminal/tree/master/ansi-terminal.cabal.
I simply turn on the C-preprocessor (CPP) and then supply -DWINDOWS on
Windows and -DUNIX on anything else. The actual use of CPP in my
source is then confined to a single module
(http://github.com/batterseapower/ansi-terminal/tree/master/System/Console/ANSI.hs)
which either imports System.Console.ANSI.Windows or
System.Console.ANSI.Unix depending on which of those two have been
defined.

Nothing to it, really. However, this is the stuff that is making the
Hackage documentation generation choke currently because until
recently Cabal forgot to supply the CPP flags to a Haddock 2 (but not
Haddock 0.x) run.

All the best,
Max
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Andrew Coppin

Max Bolingbroke wrote:

2008/9/13 Andrew Coppin [EMAIL PROTECTED]:
  

Just FYI, I have now implemented and tested this feature. The new
version, 0.5.0, is available on Hackage.
  

For both platforms?



Of course! My package promises to work cross-platform, after all.
  


[rejoyce!]


Out of interest, how do you get the correct package built on each platform?



If you mean how do I compile the ANSI emulator on Windows but the
actual ANSI stuff on Unix, most of the magic is in the .cabal file:



I simply turn on the C-preprocessor (CPP) and then supply -DWINDOWS on
Windows and -DUNIX on anything else. The actual use of CPP in my
source is then confined to a single module
which either imports System.Console.ANSI.Windows or
System.Console.ANSI.Unix depending on which of those two have been
defined.

Nothing to it, really. However, this is the stuff that is making the
Hackage documentation generation choke currently because until
recently Cabal forgot to supply the CPP flags to a Haddock 2 (but not
Haddock 0.x) run.
  


Hmm, I wasn't aware you could use the C preprocessor on Haskell source 
code. That could be rather useful, e.g., for adding or removing debug code.


Anyway, that still leaves one question: how do you figure out which 
platform you're on so you can set the right options?


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


Re: [Haskell-cafe] Windows console

2008-09-13 Thread Duncan Coutts
On Sat, 2008-09-13 at 13:41 +0100, Andrew Coppin wrote:

  If you mean how do I compile the ANSI emulator on Windows but the
  actual ANSI stuff on Unix, most of the magic is in the .cabal file:
 
  I simply turn on the C-preprocessor (CPP) and then supply -DWINDOWS on
  Windows and -DUNIX on anything else.


 Anyway, that still leaves one question: how do you figure out which 
 platform you're on so you can set the right options?

As Max suggested, look in the .cabal file. You'll find this snippet:

  if os(windows)
Build-Depends:  Win32 = 2.0
Cpp-Options:-DWINDOWS
[... other stuff ...]
  else
-- We assume any non-Windows platform is Unix
Build-Depends:  unix = 2.3.0.0
Cpp-Options:-DUNIX
[... other stuff ...]

  Extensions: CPP


Duncan

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


Re: [Haskell-cafe] Erroneous package listings in hackage?

2008-09-13 Thread Duncan Coutts
On Sat, 2008-09-13 at 12:06 +0100, Dougal Stanton wrote:
 On Sat, Sep 13, 2008 at 1:51 AM, Duncan Coutts
 [EMAIL PROTECTED] wrote:
  Perhaps for packages that are installed but not re-installable via Cabal
  (like cairo, base, ghc etc) it should say something. Do you have any
  specific suggestions?
 
 Well that explains it then! I had no idea it listed stuff not
 available from Hackage. I've been using `cabal list | grep foo` to
 search for packages but that's obviously not optimal, it seems.

I guess you're searching through the package description too. The reason
cabal list currently only searches though the name (though it does do
substring matching) is that parsing every .cabal file in the index is
rather slow. At some point we'll probably have to make a cache of the
info which we generate when the index is downloaded.

 I don't know what would clarify the matter. An available from
 Hackage: (yes/no) field? Or a flag to pass to `cabal list` to show
 Hackage stuff only?

We've got an --installed flag to list only installed stuff, we could add
one for the opposite case. You can file a feature request ticket here:

http://hackage.haskell.org/trac/hackage/

Or send us a patch! :-) I don't expect it'd be hard to add.

Duncan

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


Re: [Haskell-cafe] Re: Windows details

2008-09-13 Thread Andrew Coppin

Jeff Zaroyko wrote:

Andrew Coppin andrewcoppin at btinternet.com writes:

  

I literally cannot *believe* how hard it is to put a few little words
into that version tab... Every other kind of resource seems to be 
completely trivial, but this just won't work for toffee!



I'm sure you'll work something out, my test worked, I used a .res file I had
lying around from Wine's ddraw.dll, used windres ddraw.res -o version.o to make
an object file then using ghc hello.hs version.o linked it against hello world.
  


Well, you must either be running under a different OS or have Cygwin 
installed, because when I try it, it just complains constantly. (Can't 
find gcc, can't find cc1, can't find crt.o, and so forth.) At this 
point, I'm giving up. I only wanted this for the shininess value. It's 
not worth this much trouble...


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


Re[2]: [Haskell-cafe] Re: Windows details

2008-09-13 Thread Bulat Ziganshin
Hello Andrew,

Saturday, September 13, 2008, 5:13:21 PM, you wrote:

 Well, you must either be running under a different OS or have Cygwin
 installed, because when I try it, it just complains constantly. (Can't
 find gcc, can't find cc1, can't find crt.o, and so forth.) At this
 point, I'm giving up. I only wanted this for the shininess value. It's
 not worth this much trouble...

yes, you should add path to gcc to your path. that's what i have in my
makefile - hope it can help:

GHCDIR  = C:\Base\Compiler\ghc
LIBDIR  = $(GHCDIR)\gcc-lib
INCDIR  = $(GHCDIR)\include\mingw
GCC = $(GHCDIR)\gcc.exe -B$(LIBDIR) -I$(INCDIR)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] nooby question on typing

2008-09-13 Thread Han Joosten

Hi,

I have a question about types in Haskell. I feel that I am overlooking some
obvious solution, but I do not manage to get it right. Here is the plot:

I have got 4 different types of 'rules', each with it's own constructor.  So
i defined:

  type Rules = [Rule]
  data Rule = RuRule
| SgRule
| GcRule
| FrRule
deriving (Eq,Show)
  data RuRule
 = Ru { rrsrt :: Char
  , rrant :: Expression
  , rrfps :: FilePos
  } deriving (Eq,Show)
  data SgRule
 = Sg { srfps :: FilePos
  , srsig :: Rule
  , srxpl :: String
  , srtyp :: (Concept,Concept)
  } deriving (Eq,Show)
  data GcRule
 = Gc { grfps :: FilePos
  , grspe :: Morphism
  , grgen :: Expression
  } deriving (Eq,Show)
  data FrRule
 = Fr { fraut :: AutType
  , frdec :: Declaration
  , frcmp :: Expression
  , frpat :: String
  } deriving (Eq,Show)

Now I would like to be able to use these rules without knowing what kind
they are, in lists, however i get errors like 
Couldn't match expected type `Rule' against inferred type `SgRule'. 
Is there any other (even trivial?) way to get this done? I know Haskell well
enough to know that it is possible, but I don not know Haskell well enough
to know how to do it :teeth:

Any help is kindly appreciated!

Han Joosten
-- 
View this message in context: 
http://www.nabble.com/nooby-question-on-typing-tp19470727p19470727.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] nooby question on typing

2008-09-13 Thread Sebastian Sylvan
On Sat, Sep 13, 2008 at 2:49 PM, Han Joosten [EMAIL PROTECTED]wrote:


 Hi,

 I have a question about types in Haskell. I feel that I am overlooking some
 obvious solution, but I do not manage to get it right. Here is the plot:

 I have got 4 different types of 'rules', each with it's own constructor.
  So
 i defined:

   type Rules = [Rule]
   data Rule = RuRule
 | SgRule
 | GcRule
 | FrRule
 deriving (Eq,Show)


This effectively creates an enum type. I.e. each case here doesn't contain
any data other than the tag. I think you're getting confused because the
constructor is named the same as the type you're expecting to store. Try
something like:

  type Rules = [Rule]
  data Rule = RuRule
| MkSgRule SgRule
| MkGcRule GcRule
| MkFrRule FrRule
deriving (Eq,Show)

So MkSgRule is a tag or a label deciding which version of Rule you're
building, and it also has a value of type SgRule.

Now you can create a list or Rule like so:

mylist :: [Rule]
mylist = [ MkSgRule mysgrule, MkGcRule mygcrule ]

where mysgrule :: SgRule and mygcrule :: GcRule.


-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hackage needs a theme song!

2008-09-13 Thread Gwern Branwen
On 2008.09.12 20:35:32 -0700, Jason Dagit [EMAIL PROTECTED] scribbled 1.7K 
characters:
 I realized tonight that Hackage needs a theme song.  Here is my
 attempt at it, apologies to Jefferson Starship:

 We built this hackage,
 We built this hackage on lambda and types
...

Pretty good. Any plans to stick it in http://haskell.org/haskellwiki/Humor?

--
gwern
SUSLO Freespire INFOSEC M-x Templar Uzbekistan FID Tokyo NTT infowar


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


[Haskell-cafe] Fwd: Computer Language Benchmarks Game: [Which parallel problem would you add and why?]

2008-09-13 Thread Don Stewart
The Computer Language Benchmarks Game has a quad core (as you probably
know). But they're looking for new benchmarks. Ones that can actually
exploit parallelism. If you've got suggestions on good parallelism
benchmarks, and why they're good, add them to the alioth or reddit
threads.



- Forwarded message from Isaac Gouy -


Which parallel problem would you add and why?

http://alioth.debian.org/forum/forum.php?thread_id=14502forum_id=2840


Ask Proggit: Which parallel problem would you add now The Computer
Language Benchmarks Game is measured on quad-core hardware, and why?

http://www.reddit.com/r/programming/comments/718qf/ask_proggit_which_parallel_problem_would_you_add/


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


[Haskell-cafe] ANNOUNCE: citeproc-hs, a Haskell implementation of the Citation Style Language designed for Pandoc

2008-09-13 Thread Andrea Rossato
Hello,

I'm happy to announce the first release of citeproc-hs, a Haskell
implementation of the Citation Style Language.

citeproc-hs adds to Pandoc, the famous Haskell text processing tool, a
Bibtex like citation and bibliographic formatting and generation
facility.

ABOUT
The Citation Style Language (CSL) is an XML language for specifying
citation and bibliographic formatting, similar in principle to BibTeX
.bst files or the binary style files in commercial products like
Endnote or Reference Manager.

CSL is used by Zotero for bibliographic style formatting, and a huge
number of CSL styles have been developed by the Zotero community.

There are plans to use CSL in the future release of OpenOffice:
http://bibliographic.openoffice.org/

citeproc-hs is a library that exports functions to parse CSL styles
and MODS collections, to process lists of citation groups and to
format the processed output. The output is a Haskell data type that
can be further processed for conversion to any kind of formats (at the
present time plain ASCII and the Pandoc native format)

citeproc-hs was developed in order to add to Pandoc Bibtex like
citations and automatic reference and bibliography generation.

More information, with installation instructions, can be found here:
http://code.haskell.org/citeproc-hs/

DOWNLOADS
citeproc-hs can be downloaded from Hackage:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/citeproc-hs

To get the darcs source run:

darcs get http://code.haskell.org/citeproc-hs/


KNOWN ISSUES
citeproc-hs is in an early stage of development and the CSL is not
complete yet.

Specifically, citation collapsing is not implemented, and some
formatting options are not working neither.

The MODS parser needs some refinement too.

BUG REPORTS
To submit bug reports you can you the Google code bug tracking system
available at the following address:
http://code.google.com/p/citeproc-hs/issues


CREDITS
Bruce D'Arcus, the author of CSL, has been very kind and patient
with me when I was trying to understand the CSL schema, and provided
me with ideas, comments and suggestions that made it possible to come
to something usable.

John MacFarlane, the author of Pandoc, has been very supportive of the
project and provided a lot of useful feed back, comments and
suggestions.

Hope you'll enjoy,
Andrea Rossato
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hackage checks

2008-09-13 Thread Andrea Rossato
Hi,

the Hackage upload script performs some checks on the packages being
uploaded. In my case, a library, I need to use the cabal generated
Paths_package file to access some locale data stored in a data file
directory.

This requires to include in hs-source-dirs dist/build/autogen,
which doesn't exist in the source tree, since it's generated by cabal
in the build process (the inclusion is made necessary by a bug in
Cabal-1.2 which doesn't automatically search dist/build/autogen, see
[1]).

And so Hackage complains: I needed to manually include such an empty
directory in the source code archive.

Any way out?

TIA
Andrea


[1] http://www.haskell.org/pipermail/libraries/2008-July/010078.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] nooby question on typing

2008-09-13 Thread Ryan Ingram
So it sounds like what you want to do is this:

rulesList =
[ Ru 'a' someExpr someFilePos
, Sg someFilePos (Gc someOtherFilePos someMorphism someExpr) hello (a,b)
]
(This won't compile because Ru and Sg construct different types.)

You have a few options to do this:

1) Move the constructors into the Rule type.  This means you don't
get functions that only apply to RuRule, or any of the other types
without them being partial and subject to runtime error, so this may
not be safe enough for you.  But it is the simplest answer.

 data Rule = Ru { rrst :: Char, other stuff... } | Sg { ... } | ...

2) Smart constructors!

 data Rule = MkRu RuRule | MkSg SgRule | ...
 ru a b c = MkRu (Ru a b c)
 ...

Now just use the lowercase ru instead of Ru to construct a Rule
(instead of the specific rule type).

rulesList =
[ ru 'a' someExpr someFilePos
, sg someFilePos (Gc someOtherFilePos someMorphism someExpr) hello (a,b)
]

This will work!  You will still need the MkRu (Ru a b c) if you
pattern match on Rule, though.

3) dynamic typing and/or existential types, with smart constructors

 {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable, PatternGuards #-}
 import Data.Typeable

 data RuRule = Ru { ... } deriving (Eq, Show, Typeable)
 ...

 class Typeable a = IsRule a
 instance IsRule RuRule
 instance IsRule GcRule
 ...

 data Rule = forall a. IsRule a = Rule a

 ru a b c = Rule (Ru a b c)

 unRu :: Rule - Maybe RuRule
 unRu (Rule x) = cast x
 ...

 -- example of pattern matching using pattern guards as views
 test :: Rule - Bool
 test x
   | Just (Ru _ _ _) - unRu x = True
   | Just (Sg _ x2 _ _) - unSg x,
 Just (Ru a _ _) - unRu x2 = a == 'h'
   | otherwise = False

Hopefully one of these will suit your needs!

  -- ryan

On Sat, Sep 13, 2008 at 6:49 AM, Han Joosten [EMAIL PROTECTED] wrote:

 Hi,

 I have a question about types in Haskell. I feel that I am overlooking some
 obvious solution, but I do not manage to get it right. Here is the plot:

 I have got 4 different types of 'rules', each with it's own constructor.  So
 i defined:

  type Rules = [Rule]
  data Rule = RuRule
| SgRule
| GcRule
| FrRule
deriving (Eq,Show)
  data RuRule
 = Ru { rrsrt :: Char
  , rrant :: Expression
  , rrfps :: FilePos
  } deriving (Eq,Show)
  data SgRule
 = Sg { srfps :: FilePos
  , srsig :: Rule
  , srxpl :: String
  , srtyp :: (Concept,Concept)
  } deriving (Eq,Show)
  data GcRule
 = Gc { grfps :: FilePos
  , grspe :: Morphism
  , grgen :: Expression
  } deriving (Eq,Show)
  data FrRule
 = Fr { fraut :: AutType
  , frdec :: Declaration
  , frcmp :: Expression
  , frpat :: String
  } deriving (Eq,Show)

 Now I would like to be able to use these rules without knowing what kind
 they are, in lists, however i get errors like
 Couldn't match expected type `Rule' against inferred type `SgRule'.
 Is there any other (even trivial?) way to get this done? I know Haskell well
 enough to know that it is possible, but I don not know Haskell well enough
 to know how to do it :teeth:

 Any help is kindly appreciated!

 Han Joosten
 --
 View this message in context: 
 http://www.nabble.com/nooby-question-on-typing-tp19470727p19470727.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 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


[Haskell-cafe] Views

2008-09-13 Thread Stephan Friedrichs
Hello!

List-like data structures should IMHO provide safe versions of 'head'
and 'tail' (with safe I mean 'not partial', i. e. functions that don't
provoke an 'error' when called with an empty collection). As far as I
know, this is usually called 'view' and and has a type signature like

view :: SomeDataStructure a - View a

with

data View
  = Empty
  | Cons a (SomeDataStructure a)

A good example for this is Data.Sequence. My question is: Why is this
not expressed in terms of Maybe?

view :: SomeDataStructure a - Maybe (a, SomeDataStructure a)

This would be easier to use, as there's no need for a new View type and
because Maybe already provides instance declarations for a lot of useful
classes (Functor, Monad, etc.) and handy helper functions (e. g.
'maybe'). Then you could, for instance, say:

head xs = maybe undefined fst (view xs)
tail xs = maybe undefined snd (view xs)

You can of course argue that you want viewl and viewr to have different
types in the case of Data.Sequence, but this is not the case for other,
rather one-ended, data types, is it?

Long story short, my problem is the following: I want to provide a
'view' function for Data.Heap in my heap [1] package and I don't know
whether...

a) ... to use Maybe
b) ... to provide my own Data.Heap.View type
c) ... a Data.View package with a View type should be included in
   the containers- or even base-package. This would prevent lots of
   small projects from creating totally equivalent View types.

Maybe there even exists a Data.View package that I didn't find?

Regards,
Stephan

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/heap-0.3.1

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

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


Re: [Haskell-cafe] Views

2008-09-13 Thread Johannes Waldmann

 a) ... to use Maybe
 b) ... to provide my own Data.Heap.View type

leave the choice up to the programmer,
and provide a generic interface,
accepting any MonadZero (*) instance.

cf. Data.Set.maxView

http://www.haskell.org/hoogle/?hoogle=maxView

(*) ah - I forgot, MonadZero didn't quite make it,
instead we have fail in Monad, and mzero in MonadPlus.
Sure there must have been a reason for this...




signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Views

2008-09-13 Thread Ryan Ingram
On Sat, Sep 13, 2008 at 11:19 AM, Stephan Friedrichs
[EMAIL PROTECTED] wrote:
 data View
  = Empty
  | Cons a (SomeDataStructure a)

 A good example for this is Data.Sequence. My question is: Why is this
 not expressed in terms of Maybe?

 view :: SomeDataStructure a - Maybe (a, SomeDataStructure a)

I think the usual reason this is done is because it is clearer to
read.  Since Maybe is so generally useful, when you read code that
uses it, you have to figure out what use it is being put towards.
What does Nothing mean?  What does Just (a,b) mean? are the kinds of
questions that go through your head, and they distract you from the
problem at hand.

On the other hand, reading code that uses the View type, it is
immediately clear what Empty and Cons mean.  But you're right, Maybe
has a lot of useful helper functions and instances.

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


Re: [Haskell-cafe] Hackage checks

2008-09-13 Thread Duncan Coutts
On Sat, 2008-09-13 at 20:36 +0200, Andrea Rossato wrote:
 Hi,
 
 the Hackage upload script performs some checks on the packages being
 uploaded. In my case, a library, I need to use the cabal generated
 Paths_package file to access some locale data stored in a data file
 directory.
 
 This requires to include in hs-source-dirs dist/build/autogen,
 which doesn't exist in the source tree, since it's generated by cabal
 in the build process (the inclusion is made necessary by a bug in
 Cabal-1.2 which doesn't automatically search dist/build/autogen, see
 [1]).

Any path in your .cabal file that uses dist/ is wrong. Sorry. The dist
path can be changed by the user (--builddir) and its internal layout is
not fixed.

 And so Hackage complains: I needed to manually include such an empty
 directory in the source code archive.
 
 Any way out?

I can't think of any other workaround for 1.2 so I think you'll have to
require Cabal-1.4 for your package.

Duncan

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-13 Thread Don Stewart
dmehrtash:
I have a newbie question  Does theorem proofs have a use for an
application?  Take for example the IRC bot example
([1]http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot)  listed
below.  Is there any insight to be gained by theorem proofs (as in COQ)
into the app? 

Some customers require very high level of assurance that there are no
bugs in the code you ship to them. Theorem proving is one great way to
make those assurances.

-- Don

P.S.

publicity

In fact, it's the subject of a talk on Tuesday,

http://www.galois.com/blog/2008/09/11/theorem-proving-for-verification/

/publicity

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


Re: [Haskell-cafe] ANN: pandoc 1.0.0.1

2008-09-13 Thread John Goerzen
On Sat, Sep 13, 2008 at 09:31:50PM -0500, brian wrote:
 On Sat, Sep 13, 2008 at 8:29 PM, John MacFarlane [EMAIL PROTECTED] wrote:
  + Code is -Wall clean
 
 Thanks, I appreciate it. I wish more people paid attention to this.

Well.  I often pay attention to it.  That doesn't mean I always heed
it ;-)

Like all -Wall stuff, sometimes warnings are great and sometimes
warnings are noise.

There are two warnings that I am prone to ignore:

1) No type definition for top-level declarations

Whether or not I ignore this depends on what sort of code I'm working
on.  If I'm using Haskell as, essentially, a script language, or
writing a quick and small Parsec parser, adding a bunch of type
declarations can serve to make the code less readable and certainly
more difficult to update and maintain.  That said, for larger projects
or computation algorithms, I'd usually add declarations.

When I'm leaving off the declarations, my code sometimes winds up
looking like something vaguely resembling Python.  Sometimes time
declarations just get in the way.  Cue type inference.  One of my
favorite things about Haskell: it can be as compact as Python (or
moreso), yet detect type errors at compile time.

2) Variable x defined but not used

I most often ignore this when it occurs in a function definition.
Sometimes I may have a function that could be written

foo _ (x, _) _ = bar (x + 5)

But for clarity's sake on what all the unused args are, which really
helps for future maintainability, I'll usually use a descriptive --
but unused -- variable name.

Some of my libraries, on the other hand, are periodically validated
against -Wall -Werror.

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-13 Thread Daryoush Mehrtash
What I am trying to figure out is that say on the code for the IRC bot that
is show here

http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot/Source

What would theorem proofs do for me?

Daryoush

On Sat, Sep 13, 2008 at 9:29 PM, Don Stewart [EMAIL PROTECTED] wrote:

 dmehrtash:
 I have a newbie question  Does theorem proofs have a use for an
 application?  Take for example the IRC bot example
 ([1]http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot)  listed
 below.  Is there any insight to be gained by theorem proofs (as in
 COQ)
 into the app?

 Some customers require very high level of assurance that there are no
 bugs in the code you ship to them. Theorem proving is one great way to
 make those assurances.

 -- Don

 P.S.

 publicity

 In fact, it's the subject of a talk on Tuesday,

http://www.galois.com/blog/2008/09/11/theorem-proving-for-verification/

 /publicity


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


Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-13 Thread Thomas M. DuBuisson

 What would theorem proofs do for me?   
Imagine if you used SmallCheck to exhastively test the ENTIRE problem
space for a given property.  Now imagine you used your brain to show the
programs correctness before the heat death of the universe...

Proofs are not features, nor are they code.  What you prove is entirely
up to you and might not be what you think.  Take, for example, the issue
of proving a sort function works correctly [1].

I'm not saying this to discourage complete proofs, but just cautioning
you that proving something as unimportant and IO laden as an IRC bot
probably isn't the best example.  Do see the linked PDF, and [2] as
well.

Oh, and for examples where people should have used FM, search for
'ariane 1996'  or the gulf war patriot missle failure

TomMD

[1]
http://www.cl.cam.ac.uk/~mjcg/Teaching/SpecVer1/Lectures/pslides07x4.pdf
[2] http://users.lava.net/~newsham/formal/reverse/

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