brad clawsie | 1 May 2007 03:35
Gravatar

Re: Poor first impression

On Mon, Apr 30, 2007 at 09:53:06PM +0100, Andrew Coppin wrote:
>  brad clawsie wrote:
> > installing a modern linux on this box is a thirty minute exercise.
>
>  Ah - a volunteer! :-)

absolutely! for the low cost of one round-trip business-class seat from
san jose to wherever this box is, and i will happily insert a recent 
ubuntu cd and click the install icon.
Tom Hawkins | 1 May 2007 03:38
Picon

Re: Re: Creating pseudo terminals

On 4/29/07, Georg Sauthoff <g_sauthoff <at> web.de> wrote:
> On 2007-04-29, Tom Hawkins <tomahawkins <at> gmail.com> wrote:
>
> Hi,
>
> [..]
> > I haven't done this before in any language, so any tips would be
> > appreciated.  From what I gather, a call to posix_openpt or openpty
> > returns a master and a slave, or alternatively opening /dev/ptmx
> > followed by calls to grantpt and unlockpt.
>
> well, then I suggest 'Stevens, Advanced programming in the unix
> environment' for basic pseudo terminal programming.

Thanks for the reference.

Does Haskell's standard library support pseudo terminals, or will I
have to write foreign interfaces for grantpt and unlockpt?

-Tom
Donald Bruce Stewart | 1 May 2007 03:39
Picon
Picon
Favicon
Gravatar

Re: Re: Creating pseudo terminals

tomahawkins:
> On 4/29/07, Georg Sauthoff <g_sauthoff <at> web.de> wrote:
> >On 2007-04-29, Tom Hawkins <tomahawkins <at> gmail.com> wrote:
> >
> >Hi,
> >
> >[..]
> >> I haven't done this before in any language, so any tips would be
> >> appreciated.  From what I gather, a call to posix_openpt or openpty
> >> returns a master and a slave, or alternatively opening /dev/ptmx
> >> followed by calls to grantpt and unlockpt.
> >
> >well, then I suggest 'Stevens, Advanced programming in the unix
> >environment' for basic pseudo terminal programming.
> 
> Thanks for the reference.
> 
> Does Haskell's standard library support pseudo terminals, or will I
> have to write foreign interfaces for grantpt and unlockpt?

I'm not aware of an existing binding, so I'd suggesting writing your
own. Should be pretty simple.

-- Don
Tim Chevalier | 1 May 2007 04:14
Picon
Gravatar

Bay Area Haskell users' group, anyone?

Hello all,
With all the user groups that seem to have been forming lately, I
figure it's high time to start a Bay Area group for people interested
in Haskell (on any level). I interpret "Bay Area" broadly, since I'm
in Monterey -- perhaps encompassing all of Northern California. If
you're potentially interested, reply to me off-list, and I'll see what
kind of response I get. I imagine that the first meeting, at least,
would consist of people gathering informally over food, drink, or
such.

Cheers,
Tim

--

-- 
Tim Chevalier * chevalier <at> alum.wellesley.edu * Often in error, never in doubt
Confused? See http://catamorphism.org/transition.html
ajb | 1 May 2007 04:39
Favicon
Gravatar

Re: Bloom Filter

G'day.

Quoting tom <tom <at> almostobsolete.net>:

> I'm pretty new to Haskell, I've been working on a Bloom filter[1]
> implementation as a learning exercise.

Excellent!  Sounds like a fun test.

> I'd really appreciate it if someone more experienced would comment on
> the code. I'm sure there's plenty of places where I'm doing things in
> silly or overly complex ways.

Sure.

All in all, very well done.  It works, and it looks pretty efficient.
My quibbles are mostly stylistic or syntactic in nature.  Please
understand that the relative triviality of my quibbles is a sign that
there are really no major problems.

This is not a criticism, but more an advertisement: What are you using
for source control here?  Darcs is nice, and as a bonus, it's trivially
browsable from a web browser, which saves downloading and unpacking.

General comments:

You overuse parentheses.  A lot.  Definitions like this:

    ary = (listArray (0, wordc-1) (repeat 0))

(Continue reading)

Donald Bruce Stewart | 1 May 2007 04:45
Picon
Picon
Favicon
Gravatar

Re: Bloom Filter

ajb:
> Quoting tom <tom <at> almostobsolete.net>:
> This looks cool:
> 
>     bytes2int = foldr ((. (256 *)) . (+)) 0 . (map toInteger)
> 
> but I'm not smart enough to parse it.  This is both more readable and
> shorter:
> 
>     bytes2int = foldr (\x r -> r*256 + fromInteger x) 0
> 
> Integer log2's are probably better done using integers only, or at least
> abstracted out into a separate function.

Reminds me of this code from Data.Binary:

    unroll :: Integer -> [Word8]
    unroll = unfoldr step
      where
        step 0 = Nothing
        step i = Just (fromIntegral i, i `shiftR` 8)

    roll :: [Word8] -> Integer
    roll   = foldr unstep 0
      where
        unstep b a = a `shiftL` 8 .|. fromIntegral b

Which is a bit stream-fusion inspired, I must admit.

-- Don
(Continue reading)

Michael T. Richter | 1 May 2007 05:00
Picon
Gravatar

Re: Poor first impression

On Mon, 2007-30-04 at 18:35 -0700, brad clawsie wrote:
On Mon, Apr 30, 2007 at 09:53:06PM +0100, Andrew Coppin wrote: > brad clawsie wrote: > > installing a modern linux on this box is a thirty minute exercise. > > Ah - a volunteer! :-) absolutely! for the low cost of one round-trip business-class seat from san jose to wherever this box is, and i will happily insert a recent ubuntu cd and click the install icon.

You beat me to it.

--
Michael T. Richter <ttmrichter <at> gmail.com> (GoogleTalk: ttmrichter <at> gmail.com)
The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny..." (Isaac Asimov)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
oleg | 1 May 2007 06:12
Picon
Favicon

Type-level programming problem


Thomas Schilling wrote:
> data T
> class Foo ns a b c | ns -> a, ns -> b, ns -> c where
>      mkFoo :: ns
>      defaultA :: a
>      defaultB :: c -> IO b
>      defaultC :: [T] -> c
>      f :: c -> b -> a -> (b, Int)

> data DefaultA
> instance Foo ns a b c => Apply DefaultA ns a where
>      apply _ _ = defaultA
>
> but I get:
>
>      Could not deduce (Foo ns1 a b1 c1)
>        from the context (Apply MakeAs ns a, Foo ns a b c)
>        arising from use of `defaultA'

Indeed. Let us examine the inferred type of defaultA:
	*Main> :t defaultA
	defaultA :: (Foo ns a b c) => a

We see it is a value polymorphic over four type variables: ns, a, b,
and c. The type variable 'a' is also the type of the value, so we have
a way to instantiate it. There is no direct way to instantiate the
remaining three. If there were a functional dependency a -> ns, a->b,
a->c, we could have instantiated the remaining variables. But there
are no such dependencies. So, there is really no way we can
ever instantiate the type variables ns, b and c -- and so the typechecker
will complain.

So, we need either a functional dependency a -> ns in the definition
of Foo, or defaultA should have a signature defaultA :: ns -> a
(and ditto for other defaults). As I understand, the function
'defaultA' can be present in different components, identified by
ns. When we write 'defaultA' however, how can we say that we mean
defaultA of component X rather than of component Y? There isn't any
way to name the desired component...

Incidentally, if we represent components by records
	data XRec = XRec { defaultA :: XA }
then the type of defaultA is Xref -> XA. It is the function from the
type of the `namespace'. This seems to suggest the
signature of defaultA should be ns -> a ...

BTW, there are other ways to add the name of the namespace to the
signature of defaultA. For example:
	newtype TaggedT ns a = TaggedT a
	class Foo ns a b c | ... 
	 defaultA :: TaggedT ns a
or
	class Foo ns a b c | ... 
	 defaultA :: ns a

etc.
Magnus Therning | 1 May 2007 10:34
Gravatar

Cabal, lib and exe in one

I'm trying to create a single cabal file containing specs for both a
library and an executable using that library.  I'm not having much luck
though :(

This is what I have so far:

  name: foo
  version: 0.1
  exposed-modules: Foo.Bar
  other-modules: Foo.Qux Foo.C2HS
  hs-source-dirs: src
  include-dirs: csrc
  c-sources: csrc/qux.c
  extensions: ForeignFunctionInterface
  build-depends: base, haskell98

  executable: foo
  hs-source-dirs: test-src
  main-is: foo.hs
  other-modules: Foo.Bar

When built this is the message I get:
  test-src/foo.hs:5:7:
      Could not find module `Foo.Bar':
        Use -v to see a list of the files searched for.

How do I specify that Foo.Bar is found where cabal puts it
(./dist/build/)?

/M

--

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus <at> therning.org             Jabber: magnus.therning <at> gmail.com
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Fifth Law:
Always draw your curves, then plot your readings.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Bayley, Alistair | 1 May 2007 11:09
Picon
Favicon

RE: FIT for Haskell

> From: haskell-cafe-bounces <at> haskell.org 
> [mailto:haskell-cafe-bounces <at> haskell.org] On Behalf Of Philipp Volgger
> 
> Who wrote FIT for Haskell on http://darcs.haskell.org/FIT/? 
> Does anybody know if the version is stable?

Hello Philipp,

That would be me. It's not finished or stable, and I don't think it'll
work with GHC-6.6 on Windows because it uses hs-plugins. I figured I'd
better save the code somewhere, because I lost some work when my laptop
died last year.

It's not finished in the sense that I haven't implemented all of the
test suite; I got as far as the Music Example in the standard tests
(http://fit.c2.com/wiki.cgi?MusicExample) but I have not implemented
RowFixture, which the Music Example requires. Also, the
Algol-derivative-language implementations of FIT (Java, C#, etc) use
static class variables (i.e. global mutable state) in the Music Example,
so there's some redesign work to get it to run in Haskell.

I'd be happy to explain how it works if you're interested in
contributing.

Alistair
*****************************************************************
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*****************************************************************

Gmane