From allbery.b at gmail.com Sun Mar 1 00:00:15 2015
From: allbery.b at gmail.com (Brandon Allbery)
Date: Sat, 28 Feb 2015 19:00:15 -0500
Subject: [Haskell-cafe] A Question about IO
In-Reply-To:
References:
Message-ID:
On Sat, Feb 28, 2015 at 6:40 PM, Zongzhe Yuan
wrote:
> Sometimes IO do something and return something, i wonder if the return
> type, for example is IO Int means it will return an int, could i purely
> fetch the int?
Conceptually, an IO something is a *program* that can produce, not under
your control, a something. You create this program and return it as the
value of (main :: IO a); then the runtime executes it.
(Actually, what happens in GHC is different. There are ways to get at the
value --- but you have to dig into GHC internals and use them to lie to
GHC, and it will punish you for it by (among other things) treating it as a
pure value and memoizing, sharing (or not sharing when you expect it to),
etc. as it sees fit. In short: don't. This is not some thing to force you
to jump through hoops for no good reason, with an easy escape hatch to get
the behavior you'd get from a random Perl/Java/whatever program; if you go
around its back, things *will* break unless you understand how GHC works.)
There is nothing in Monad that guarantees that you can go from Monad m => m
a -> a. Specific Monad-s (lists, Maybe, etc.) may provide functions to do
so, or expose their data constructors so that you can pattern match them;
other Monad-s (IO, ST, STM) do not, and you cannot get at "the value
inside" --- indeed, there may not be a value inside. (This isn't even
specific to Monad; you can't pattern match a Data.Map.Map, either, and it's
not a Monad. It does provide toList, though, as well as its own access
methods.)
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From lambda.fairy at gmail.com Sun Mar 1 00:01:07 2015
From: lambda.fairy at gmail.com (Chris Wong)
Date: Sun, 1 Mar 2015 13:01:07 +1300
Subject: [Haskell-cafe] is it possible to implement Functor for
ByteString and Text
In-Reply-To: <54F212C9.6040509@gmail.com>
References: <54F212C9.6040509@gmail.com>
Message-ID:
On Sun, Mar 1, 2015 at 8:11 AM, silvio wrote:
> I have recently heard that some people want to burn bridges (introducing
> Foldable and Traversable to Prelude) and I've been wondering if it was
> possible somehow allow Text and Bytestring like containers to make use
> of those functions. Something along the lines of
>
> import qualified Data.ByteString as BS
>
> newtype ByteString' a = ByteString' BS.ByteString
>
> type ByteString = ByteString' Word8
>
> instance (ByteString' a ~ ByteString' Word8) => Functor (ByteString')
> where
> fmap f (ByteString' bs) = ByteString' $ BS.map f bs
If tweak the definition of Functor a bit, we can get that to work:
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}
import qualified Data.ByteString as B
import Data.Word (Word8)
import GHC.Prim (Constraint)
newtype ByteString' a = ByteString' B.ByteString
deriving (Eq, Ord, Show)
class Functor' f where
type FunctorConstraint f a :: Constraint
fmap' :: (FunctorConstraint f a, FunctorConstraint f b) => (a ->
b) -> f a -> f b
instance Functor' ByteString' where
type FunctorConstraint ByteString' a = a ~ Word8
fmap' f (ByteString' x) = ByteString' $ B.map f x
But I don't think it's possible with the original type class.
--
https://lambda.xyz
From travis.cardwell at extellisys.com Sun Mar 1 00:42:10 2015
From: travis.cardwell at extellisys.com (Travis Cardwell)
Date: Sun, 01 Mar 2015 09:42:10 +0900
Subject: [Haskell-cafe] What other prelude to cleanly convert text-files
into json
In-Reply-To:
References:
Message-ID: <54F26062.8020007@extellisys.com>
On 2015?02?28? 20:23, Bram Neijt wrote:
> It quickly became a collection of "import qualified" and "T.unpack,
> T.pack" calls that made the whole thing look ugly [1].
> [1] Source can be read here: https://gist.github.com/bneijt/9bdb4b1759790a8463c9
File paths are of type `System.FilePath.Posix.FilePath`, a type alias for
`String`. Note that this convention is also followed in `ByteString` and
`Text` libraries; they do not use `ByteString` or `Text` types for the
file paths.
In this code, file paths are packed only to have to unpack them again
(twice!), which likely offsets any performance improvements of using the
`Text` version of `isSuffixOf`.
Here is a version using the same style but without packing file paths:
https://gist.github.com/TravisCardwell/fd9981e4968e4af3751d
I included a few other changes, which are commented in the code.
By the way, I do not think that qualified imports are bad. I like them
because they provide an explicit reference to the source module of a function.
Cheers,
Travis
From silvio.frischi at gmail.com Sun Mar 1 01:08:40 2015
From: silvio.frischi at gmail.com (silvio)
Date: Sun, 01 Mar 2015 02:08:40 +0100
Subject: [Haskell-cafe] is it possible to implement Functor for
ByteString and Text
In-Reply-To:
References: <54F212C9.6040509@gmail.com>
Message-ID: <54F26698.3000207@gmail.com>
Wow ConstraintKinds. There's always a new extension to be learned :)
Anyway, if changing the Functor declaration were allowed, it would
probably make more sense to use something like MonoFunctor.
Unfortunately, MPTC or type family stuff is never going to make it into
Prelude.
Silvio
From haskell at nand.wakku.to Sun Mar 1 02:58:15 2015
From: haskell at nand.wakku.to (Niklas Haas)
Date: Sun, 1 Mar 2015 03:58:15 +0100
Subject: [Haskell-cafe] is it possible to implement Functor for
ByteString and Text
In-Reply-To: <54F26698.3000207@gmail.com>
References: <54F212C9.6040509@gmail.com>
<54F26698.3000207@gmail.com>
Message-ID: <20150301035815.GB25080@nanodesu.localdomain>
I think it's more realistic to use lens style Setters where possible.
Essentially:
type Setter s t a b = (a -> b) -> s -> t
type Setter' s a = Setter s s a a
bytes :: Setter ByteString Word8
bytes = BS.map
fmapped :: Functor f => Setter (f a) (f b) a b
fmapped = fmap
In this framework, you could write a function that can abstract over any
setter, eg.
changeSomething :: Setter s t Foo Bar -> s -> t
changeSomething s = s fooBar
where fooBar :: Foo -> Bar
It's not quite the same thing as making ByteString or Text an instance
of Functor, but for some tasks, it can be a good replacement.
On Sun, 01 Mar 2015 02:08:40 +0100, silvio wrote:
> Wow ConstraintKinds. There's always a new extension to be learned :)
> Anyway, if changing the Functor declaration were allowed, it would
> probably make more sense to use something like MonoFunctor.
> Unfortunately, MPTC or type family stuff is never going to make it into
> Prelude.
>
> Silvio
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From amindfv at gmail.com Sun Mar 1 04:51:52 2015
From: amindfv at gmail.com (amindfv at gmail.com)
Date: Sat, 28 Feb 2015 23:51:52 -0500
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To: <20150228185026.GA10871@x60s.casa>
References: <20150228172448.0B40EBC942@haskell.org>
<20150228185026.GA10871@x60s.casa>
Message-ID: <55E30478-64E2-4B76-B049-B42A8EF21074@gmail.com>
IIRC hackage doesnt accept AllRightsReserved packages (or at least sdist warns about it strongly)
Tom
El Feb 28, 2015, a las 13:50, Francesco Ariis escribi?:
> On Sat, Feb 28, 2015 at 07:27:16PM +0200, fr33domlover wrote:
>> I'd like to make a suggestion: have Hackage accept only packages
>> released under free software licenses. This is probably true for
>> most/all packages there, but making it official will both send a
>> strong message to and from the community, and provide people with
>> the security and peace of mind, knowing their software is free as
>> in freedom.
>
> I was pretty sure there was a note somewhere on hackage to only upload
> software with open source licences, but alas I cannot find it now...
> (maybe I am confusing myself with another package archiver?).
>
> I agree having a "please use a licence approved by the OSI/FSF" could
> prevent problems and seems a sensible choice in any case.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From gershomb at gmail.com Sun Mar 1 05:17:17 2015
From: gershomb at gmail.com (Gershom B)
Date: Sun, 1 Mar 2015 00:17:17 -0500
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
Message-ID:
For the record, the current behaviour is as follows.
A package with AllRightsReserved as a license or a missing license is now rejected by ?cabal check? with the following:
==
* The 'license' field is missing or specified as AllRightsReserved.
Hackage would reject this package.
==
A package with an unknown license such as ?Foo? is rejected with the following:
==
* 'license: Foo' is not a recognised license. The known licenses are: GPL,
GPL-2, GPL-3, LGPL, LGPL-2.1, LGPL-3, AGPL, AGPL-3, BSD2, BSD3, MIT, MPL-2.0,
Apache, Apache-2.0, PublicDomain, AllRightsReserved, OtherLicense
Hackage would reject this package.
==
However, a package with OtherLicense is indeed accepted.
It would be good to specify that we ask that OtherLicense indeed be another recognized open-source license. That said, I do not feel strongly about how much care we take to enforce this. We should definitely better document this and other elements of hackage policy, and I know discussions about that have in fact been underway.
I agree that being able to filter Hackage packages on license and other considerations (say, build reports on various systems) would be a great feature. Some such improvements have been floated as GSoC projects. I would encourage those that feel strongly about such features to consider getting involved with development of the hackage server.
Cheers,
Gershom
On February 28, 2015 at 4:29:39 PM, Mike Meyer (mwm at mired.org) wrote:
> On Sat, Feb 28, 2015 at 2:59 PM, Francesco Ariis wrote:
>
> > Those restrictions would be, in my opinion, a good idea. Rejecting
> > say CC-SA (CC0 is FSF approved), etc. code means rejecting licences
> > with clear and documented problems in them, problems which would
> > cause quite a lot of headaches down the road.
> >
>
> I don't have a problem if you want to do that. But by disallowing those
> licenses on Hackage, you've taken away *MY* ability to decide if those
> problems are problems for my use case.
>
> There are open source projects that are systematically excising GPL'ed
> software because of the problems it shares with ShareAlike licenses. Should
> we disallow the GPL because some people have problems with it?
>
> Making Hackage better to help users sort out which licenses they are
> willing to accept in their project - which I personally would like to do on
> a project-by-project basis! - is a solution to these problems. Restricting
> the licenses that are acceptable on Hackage to meet some arbitrary set of
> criteria is a knee-jerk.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
From sean.seefried at gmail.com Sun Mar 1 06:09:14 2015
From: sean.seefried at gmail.com (Sean Seefried)
Date: Sun, 1 Mar 2015 17:09:14 +1100
Subject: [Haskell-cafe] ghci and dynamically linking to Objective-C objects
on Mac OS X
Message-ID:
Hi all,
I fear I might be unaware of something I should be. Say I have a file
objc_util.m with the following contents:
#include
void ns_log(const char *s) {
NSString *str = [NSString stringWithUTF8String:s];
NSLog(@"%@", str);
}
I also have a file Main.hs with contents:
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
import Foreign.C.Types
import Foreign.C.String
foreign import ccall "ns_log" cNSLog :: CString -> IO ()
nsLog s = withCString s cNSLog
I compile objc_util.m with:
gcc -c objc_util.m
And then I try to open it up in GHCi.
ghci objc_util.o Main.hs -framework Foundation
I add the flag '-frame Foundation' in the hopes that symbols in objc_util.o
will get resolved
dynamically.
However I get:
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading object (static) objc_util.o ... ghc: panic! (the 'impossible'
happened)
(GHC version 7.8.3 for x86_64-apple-darwin):
Loading temp shared object failed:
dlopen(/var/folders/pv/pfxcyy117v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib,
9): Symbol not found: _OBJC_CLASS_$_NSString
Referenced from: /var/folders/pv/pfxcyy1
17v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib
Expected in: flat namespace
in
/var/folders/pv/pfxcyy117v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
However, I have found a work around to this. If I do this:
ln -s /System/Library/Frameworks/Foundation.framework/Foundation
Foundation.o
and then run
ghci Foundation.o objc_util.o Main.hs
I get this:
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading object (static) Foundation.o ... done
Loading object (static) objc_util.o ... done
final link ... done
Everything has worked! And I can happily run 'nsLog' from GHCi and have it
appear in the
'Console' app.
However, it doesn't seem like I should have to do this. Where am I going
wrong?
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From allbery.b at gmail.com Sun Mar 1 07:25:10 2015
From: allbery.b at gmail.com (Brandon Allbery)
Date: Sun, 1 Mar 2015 02:25:10 -0500
Subject: [Haskell-cafe] ghci and dynamically linking to Objective-C
objects on Mac OS X
In-Reply-To:
References:
Message-ID:
On Sun, Mar 1, 2015 at 1:09 AM, Sean Seefried
wrote:
> However, it doesn't seem like I should have to do this. Where am I going
> wrong?
My guess is that the linker used by ghci (which is not the system linker,
although there is ongoing work on that front) doesn't know how to deal with
frameworks properly. You might have better luck turning your .o into a
.dylib and linking *that* against the Foundation framework.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From fr33domlover at riseup.net Sun Mar 1 09:03:10 2015
From: fr33domlover at riseup.net (fr33domlover)
Date: Sun, 1 Mar 2015 11:03:10 +0200
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<54f21a89.ed16460a.1d6a.ffff9ddcSMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
Hello Mike,
I think there's some confusion here. I wan't talking about GPL compatible
licenses, but about *any* free software license!
It looks like Creative Commons licenses may apply too, in particular the
version 4 ones. CC by 4 is even GPL-compatible.
The same for EPL and CDDL! Check out this:
http://www.gnu.org/licenses/license-list.html
Both are free sofware licenses. GPL compatibility isn't the issue here :)
On Sat, 28 Feb 2015 14:18:23 -0600
Mike Meyer wrote:
>
> And what if I want something like the CDDL or the EPL? Those are both
> licenses that the OSI says are popular.
>
The FSF approves them as well, like I said.
>
> You're addressing the nits, not the core issue I tried to raise:
> placing restrictions on what licenses (or lack thereof) are acceptable
> will discourage people from making software available via Hackage.
I don't think it will, because people are already making free software. Look at
other existing hosting services - they're *full* of free software! This is what
people are making anyway. All I suggest is to make it official, providing a
guarantee so people know each `cabal install` indeed installs only free
software.
> >
> > This will allow people to upload first, and then think and understand the
> > licensing situation. Once they do, they can properly tag their project.
> Could
> > that work?
>
> I don't know. I suspect that if you do that, a lot of people would
> never bother tagging their packages. Would that work for you?
They probably will, actually: There is a huge number of packages - I don't know
how many - which have license tags. All the license tags on Hackage except for
the all-rights-reserved one are FOSS licenses, so all of these would instantly
become available as guaranteed free software packages.
How many free software packages on Haskell don't have license tags?
> You also talk like free/non-free was a binary decision, when it
> isn't. The OSI lists licenses that aren't compatible with the GPL -
> like the aforementioned EPL and CDDL. People releasing software under
> one of those will want to avoid GPL licensed software, whereas people
> releasing GPL licensed software will want to avoid those licenses, but
> they are all free.
Indeed they are all free, and the FSF approves them officially as well. MIT,
BSD, Apache, EPL, CDDL, GPL, AGPL, LGPL... all of these are free software
licenses.
> Or I may not care. If I build a binary that uses one package that's
> GPL-licensed and one that uses an incompatible OSI-approved license, I
> can distribute my source under whatever terms I want, because my
> source doesn't include source from those packages. I can build and run
> binaries myself with no problems, and that may be fine. But I can't
> distribute binaries because I can't satisfy both licenses
> simultaneously, and that may not be acceptable.
>
>
References: <54F17EFF.7010902@home.nl> <54F1A184.8060800@home.nl> <54F1C524.4060706@home.nl> <54F1FB13.3040206@home.nl>
Message-ID: <54F2E745.7050505@home.nl>
An HTML attachment was scrubbed...
URL:
From k-bx at k-bx.com Sun Mar 1 10:25:06 2015
From: k-bx at k-bx.com (Konstantine Rybnikov)
Date: Sun, 1 Mar 2015 12:25:06 +0200
Subject: [Haskell-cafe] A Question about IO monad
In-Reply-To:
References:
Message-ID:
Hi Zongzhe,
You can indeed write "Maybe a -> a" function easy, because you have Maybe
constructors exported for you. But please note that this will lead to
non-total function, e.g. it will have to return an error in case of call
with Nothing, so you should avoid writing and using functions like this.
IO case is even less safe, since IO is a special monad (its constructor is
not exported), and you should want to do something like this even less, but
still, you have functions like unsafePerformIO that have type "IO a -> a".
But most probably if you need it -- you're doing something wrong.
If you got to "IO a" value -- you should continue writing functions that
operate in IO, and if you want to apply pure function to inner value, you
can do it like this:
main = do
i
???????:
> Hi
> i have a question about IO monad.
> Sometimes IO do something and return something, i wonder if the return
> type, for example is IO Int means it will return an int, could i purely
> fetch the int?
> but i fail, i cannot construct a function, i use do notation but i found i
> must use something to pass the int to another monad.
> But i could write a function has the type of Maybe a -> a and it is easily.
> Maybe monad and IO monad both instance monad but why i can?t do that?
>
>
> Zongzhe Yuan
>
>
>
> This message and any attachment are intended solely for the addressee
> and may contain confidential information. If you have received this
> message in error, please send it back to me, and immediately delete it.
>
> Please do not use, copy or disclose the information contained in this
> message or in any attachment. Any views or opinions expressed by the
> author of this email do not necessarily reflect the views of the
> University of Nottingham.
>
> This message has been checked for viruses but the contents of an
> attachment may still contain software viruses which could damage your
> computer system, you are advised to perform your own checks. Email
> communications with the University of Nottingham may be monitored as
> permitted by UK legislation.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From r.wobben at home.nl Sun Mar 1 11:18:53 2015
From: r.wobben at home.nl (Roelof Wobben)
Date: Sun, 01 Mar 2015 12:18:53 +0100
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <54F2E745.7050505@home.nl>
References: <54F17EFF.7010902@home.nl> <54F1A184.8060800@home.nl> <54F1C524.4060706@home.nl> <54F1FB13.3040206@home.nl>
<54F2E745.7050505@home.nl>
Message-ID: <54F2F59D.6070901@home.nl>
An HTML attachment was scrubbed...
URL:
From nikita at karetnikov.org Sun Mar 1 11:58:17 2015
From: nikita at karetnikov.org (Nikita Karetnikov)
Date: Sun, 01 Mar 2015 14:58:17 +0300
Subject: [Haskell-cafe] A Question about IO monad
In-Reply-To:
(Konstantine Rybnikov's message of "Sun, 1 Mar 2015 12:25:06 +0200")
References:
Message-ID: <87r3t9expi.fsf@karetnikov.org>
> You can indeed write "Maybe a -> a" function easy, because you have Maybe
> constructors exported for you. But please note that this will lead to
> non-total function, e.g. it will have to return an error in case of call
> with Nothing, so you should avoid writing and using functions like this.
A tiny nitpick: you can get a total function if you return a default
value instead of erroring out.
>> Sometimes IO do something and return something, i wonder if the return
>> type, for example is IO Int means it will return an int, could i purely
>> fetch the int?
The IO in IO Int means that instead of just returning an Int, a
computation may produce a side-effect (like writing a string to standard
output). Since reasoning about code without side-effects is much
simpler, you want to separate it from impure code. That's what IO is
for. Once you're inside IO, you're dealing with impure code, so you
want to keep track of things that rely on it. You can't* and don't want
to escape.
* As Konstantine points out, there are legitimate cases for using
unsafePerformIO, like writing an FFI binding to a pure function.
Haskell type system can't see whether the function in question is pure
or not, so it's tagged with IO. However, if you know that it's pure,
you can explicitly state that by using unsafePerformIO.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL:
From mwm at mired.org Sun Mar 1 12:19:40 2015
From: mwm at mired.org (Mike Meyer)
Date: Sun, 1 Mar 2015 06:19:40 -0600
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To: <54f2d5d5.4289460a.3c84.572eSMTPIN_ADDED_MISSING@mx.google.com>
References: <20150228172446.3CB4EBC986@haskell.org>
<54f21a89.ed16460a.1d6a.ffff9ddcSMTPIN_ADDED_MISSING@mx.google.com>
<54f2d5d5.4289460a.3c84.572eSMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Sun, Mar 1, 2015 at 3:03 AM, fr33domlover
wrote:
> Hello Mike,
> I think there's some confusion here. I wan't talking about GPL compatible
> licenses, but about *any* free software license!
According to Gershom's letter, it already does that. Or at least
"cabal check" does.
> It looks like Creative Commons licenses may apply too, in particular the
> version 4 ones. CC by 4 is even GPL-compatible.
> The same for EPL and CDDL! Check out this:
> http://www.gnu.org/licenses/license-list.HTML
> Both are free sofware licenses. GPL compatibility isn't the issue here :)
That URL gets a 404 error. However, if you look at this page:
http://www.gnu.org/licenses/license-list.HTML you'll find that the EPL
and CDDL are listed as incompatible. The CC licenses are only
mentioned as non-software licenses, and not all of them are
listed. Nuts, it's even documented that the CC licenses aren't all
compatible with each other!
https://wiki.creativecommons.org/Wiki/cc_license_compatibility
> > And what if I want something like the CDDL or the EPL? Those are both
> > licenses that the OSI says are popular.
> The FSF approves them as well, like I said.
Well, I found them on a free license list. Of course, some of those
include things like "We urge you not to use the CDDL" in them, which
hardly sounds like approval to me.
5
> > You're addressing the nits, not the core issue I tried to raise:
> > placing restrictions on what licenses (or lack thereof) are acceptable
> > will discourage people from making software available via Hackage.
> I don't think it will, because people are already making free software.
Look at
> other existing hosting services - they're *full* of free software! This
is what
> people are making anyway. All I suggest is to make it official, providing
a
> guarantee so people know each `cabal install` indeed installs only free
> software.
As long as you're willing to accept any license that the author thinks
of as free, then it won't. But that's such a broad scope as to make
this change effectively negligible, even from my nit-picking
standpoint.
> > Or I may not care. If I build a binary that uses one package that's
> > GPL-licensed and one that uses an incompatible OSI-approved license, I
> > can distribute my source under whatever terms I want, because my
> > source doesn't include source from those packages. I can build and run
> > binaries myself with no problems, and that may be fine. But I can't
> > distribute binaries because I can't satisfy both licenses
> > simultaneously, and that may not be acceptable.
> That's true, but eventually you wouldn't want to do that. I mean, if you
build
> some program, you'd be happy to have it packaged for distros and make
binary
> releases for people who don't want to build from source.
Sure, I may be happy to have the binaries build and packaged for all
distros. Then again, I know there are people building software using
Haskell - and hence hackage or stackage - that aren't planning on
distributing the software in any form, so don't care about this issue.
For me personally, the FreeBSD package system allows for adding things
that have to be built from source for some reason or another, and make
building them as easy as installing the binaries. I'm happy providing
FreeBSD ports, but making it possible for people building packages for
less flexible systems who actually check all the licenses involved
isn't something I'm going to spend a lot of effort on.
And you're proposed change - or possibly non-change, given what
Gershom reported - won't change that effort. All the licenses
involved are free. However, some of them aren't compatible with each
other, so the only way to fix this is to use different packages. I
suppose I could try and get some of the authors to change their
license, but that's probably even more work.
> This is essentially the question I'm asking the community: do you care
about
> the packages being free software, allowing legal distribution of binaries?
> Specifically, would you make a step forward and make it official, build-in
> into Hackage?
Except you can't answer the question "does it allow legal distribution
of binaries" by just looking at the license on the package. You also
have to consider the licenses on the transitive closure of the
libraries it uses, as they will be included in the binary, or at least
dynamically linked to it, and thus may be considered a derivative work
of the packages it includes. So your binary has to comply with the
terms of all those licenses, which may not be possible even if all the
licenses are approved by the OSI or on the FSF's list of free
licenses.
Which is also why even the relatively minor restriction "must allow
free redistribution of binaries" isn't one I'd be happy with. Sure, it
probably won't affect most people. But it equally won't help most
people who want to distribute binaries, because it only removes a
minor source of barriers to doing so.
Unless, of course, by "must allow free redistribution of binaries",
you mean "doesn't place any restrictions whatsoever on the
distribution of binaries", which would eliminate the not only many of
the CC licenses, but also the GPL and some of the BSD licenses.
From s9gf4ult at gmail.com Sun Mar 1 12:30:36 2015
From: s9gf4ult at gmail.com (Alexey Uimanov)
Date: Sun, 1 Mar 2015 18:30:36 +0600
Subject: [Haskell-cafe] ANNOUNCE postgresql-query and postgresql-config
Message-ID:
Hi guys! Here is yet another some-level library to work with PostgreSQL DB.
http://hackage.haskell.org/package/postgresql-query
This library uses `postgresql-query` and is a list of helpers/workarounds
to generate
complex queries more safely and parse result.
What it contains:
1. interplating quasiquote `sqlExp` which uses instances of `ToField`
typeclass to paste
values inside query.
It looks like this:
let val = "'hello'" :: Text
q = [sqlExp|SELECT field1 FROM tbl WHERE field2 = #{val}|]
where `val` is an arbitrary Haskell expression which type has instance
of `ToField`
Resulting query will be like:
"SELECT field1 FROM tbl WHERE field2 = '''hello'''"
Yes, proper string escaping is performed authomatically like using this
'?'-like
queries with parameters.
Resulting type of quasiquote is `SqlBuilder` which uses bytestring
builders inside and
can be concatenated efficiently.
There is also posibility to paste one query inside another like:
let q2 = [sqlExp|SELECT field1 f FROM (^{q}) WHERE field1 is not null|]
so `q2` will generate nested query.
sqlExp also removes SQL comments and removes long sequences of space
characters. It also
properly handles string literals and quoted identifiers inside
quasiquotes.
2. Typeclass `HasPostgres`, simple connection reader `PgMonadT` and
functions like
`pgQuery` to perform queries.
http://hackage.haskell.org/package/postgresql-query-1.0.1/docs/Database-PostgreSQL-Query-Functions.html
3. TH functions to authomatically derive `FromRow` and `ToRow` instances
(from postgresql-simple)
http://hackage.haskell.org/package/postgresql-query-1.0.1/docs/Database-PostgreSQL-Query-TH.html
4. Some kind of primitive pre-ORM which generates queries for CRUD-ing
simple record types.
It looks like:
data User = User
{ userName :: !Text
, userPasswordEncrypted :: !Text
} deriving (Show, Eq, Ord, Typeable)
type UserId = EntityId User
$(deriveFromRow ''User)
$(deriveToRow ''User)
instance Entity User where
newtype EntityId User
= UserId { unUserId :: UUID } -- Note that you can use any type
for id
deriving (Show, Read, Ord, Eq,
FromField, ToField, PathPiece) -- To use with Yesod
tableName _ = "users"
fieldNames _ = [ "name"
, "password_encrypted" ]
runPgMonadT con $ do
uid
From adam at bergmark.nl Sun Mar 1 13:17:36 2015
From: adam at bergmark.nl (Adam Bergmark)
Date: Sun, 1 Mar 2015 14:17:36 +0100
Subject: [Haskell-cafe] A Question about IO monad
In-Reply-To: <87r3t9expi.fsf@karetnikov.org>
References:
<87r3t9expi.fsf@karetnikov.org>
Message-ID:
On Sun, Mar 1, 2015 at 12:58 PM, Nikita Karetnikov
wrote:
> > You can indeed write "Maybe a -> a" function easy, because you have Maybe
> > constructors exported for you. But please note that this will lead to
> > non-total function, e.g. it will have to return an error in case of call
> > with Nothing, so you should avoid writing and using functions like this.
>
> A tiny nitpick: you can get a total function if you return a default
> value instead of erroring out.
>
>
What default value would you return for the function `Maybe a -> a`?
- Adam
> >> Sometimes IO do something and return something, i wonder if the return
> >> type, for example is IO Int means it will return an int, could i purely
> >> fetch the int?
>
> The IO in IO Int means that instead of just returning an Int, a
> computation may produce a side-effect (like writing a string to standard
> output). Since reasoning about code without side-effects is much
> simpler, you want to separate it from impure code. That's what IO is
> for. Once you're inside IO, you're dealing with impure code, so you
> want to keep track of things that rely on it. You can't* and don't want
> to escape.
>
> * As Konstantine points out, there are legitimate cases for using
> unsafePerformIO, like writing an FFI binding to a pure function.
> Haskell type system can't see whether the function in question is pure
> or not, so it's tagged with IO. However, if you know that it's pure,
> you can explicitly state that by using unsafePerformIO.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From nikita at karetnikov.org Sun Mar 1 14:07:59 2015
From: nikita at karetnikov.org (Nikita Karetnikov)
Date: Sun, 01 Mar 2015 17:07:59 +0300
Subject: [Haskell-cafe] A Question about IO monad
In-Reply-To: (Adam
Bergmark's message of "Sun, 1 Mar 2015 14:17:36 +0100")
References:
<87r3t9expi.fsf@karetnikov.org>
Message-ID: <87mw3wg69s.fsf@karetnikov.org>
>> A tiny nitpick: you can get a total function if you return a default
>> value instead of erroring out.
>>
>>
> What default value would you return for the function `Maybe a -> a`?
You can do it with unsafeCoerce, but there are restrictions. And that's
not what I meant, sorry. I mentally substituted an a for an Int:
f :: Maybe Int -> Int
f (Just x) = x
f Nothing = 0
And there's also the maybe function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL:
From marcin.jan.mrotek at gmail.com Sun Mar 1 14:27:15 2015
From: marcin.jan.mrotek at gmail.com (Marcin Mrotek)
Date: Sun, 1 Mar 2015 15:27:15 +0100
Subject: [Haskell-cafe] A Question about IO monad
In-Reply-To: <87mw3wg69s.fsf@karetnikov.org>
References:
<87r3t9expi.fsf@karetnikov.org>
<87mw3wg69s.fsf@karetnikov.org>
Message-ID:
But this is exactly the point: there can be no total, generic function of type
f :: Monad m => m a -> a
(though there is for a Comonad ;))
As for Zongzhe Yuan's original question, i thinks it's safe to think
of a value of type (IO a) as a program that, when executed, will
result in a value of type a. This program can be copied, stored in a
variable, passed to another thread, etc. It will only be actually
executed when (perhaps after being combined with other IO programs)
bound to the main program.
Kind regards,
Macin Mrotek
From bneijt at gmail.com Sun Mar 1 16:47:22 2015
From: bneijt at gmail.com (Bram Neijt)
Date: Sun, 1 Mar 2015 17:47:22 +0100
Subject: [Haskell-cafe] What other prelude to cleanly convert text-files
into json
In-Reply-To: <54F26062.8020007@extellisys.com>
References:
<54F26062.8020007@extellisys.com>
Message-ID:
Thank you all for the responses.
Qualified imports for a script of less then a page make the code less
readable. That is why I want to specifically import subsets of
functions and not prefix everything with qualified imports.
I've taken the code from Travis (clean up some of the useless
pack/unpack), decided to use "NoImplicitPrelude" and then I had this:
#!/usr/bin/runghc
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
import Prelude (Show, IO, (++), print, String, filter)
import Data.List (isSuffixOf)
import Data.Text hiding (isSuffixOf, filter)
import Data.Text.IO
import Control.Monad (mapM_)
import qualified Data.ByteString.Lazy as BL
import System.Directory (getDirectoryContents)
import System.FilePath.Posix ((), FilePath, takeBaseName)
import Data.Aeson
data Product = Product
{ image :: Text
, description :: Text
} deriving Show
instance ToJSON Product where
toJSON (Product image description) = object ["image" .= image,
"description" .= description]
encodeToJson :: FilePath -> IO()
encodeToJson srcName = do
let jsonName = takeBaseName srcName "json"
contents BL.writeFile jsonName (encode Product {
image = firstLine,
description = unlines restLines
})
_ -> print ("error: invalid source file: " ++ srcName)
main = do
names wrote:
> On 2015?02?28? 20:23, Bram Neijt wrote:
>> It quickly became a collection of "import qualified" and "T.unpack,
>> T.pack" calls that made the whole thing look ugly [1].
>
>> [1] Source can be read here: https://gist.github.com/bneijt/9bdb4b1759790a8463c9
>
> File paths are of type `System.FilePath.Posix.FilePath`, a type alias for
> `String`. Note that this convention is also followed in `ByteString` and
> `Text` libraries; they do not use `ByteString` or `Text` types for the
> file paths.
>
> In this code, file paths are packed only to have to unpack them again
> (twice!), which likely offsets any performance improvements of using the
> `Text` version of `isSuffixOf`.
>
> Here is a version using the same style but without packing file paths:
> https://gist.github.com/TravisCardwell/fd9981e4968e4af3751d
>
> I included a few other changes, which are commented in the code.
>
> By the way, I do not think that qualified imports are bad. I like them
> because they provide an explicit reference to the source module of a function.
>
> Cheers,
>
> Travis
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From michael at snoyman.com Sun Mar 1 16:52:49 2015
From: michael at snoyman.com (Michael Snoyman)
Date: Sun, 01 Mar 2015 16:52:49 +0000
Subject: [Haskell-cafe] What other prelude to cleanly convert text-files
into json
References:
<54F26062.8020007@extellisys.com>
Message-ID:
The trick with ClassyPrelude is to use the system-fileio package instead of
straight directory. With that in place, you get:
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
import ClassyPrelude
import Data.Aeson
import Filesystem (listDirectory)
data Product = Product
{ image :: Text
, description :: Text
} deriving Show
instance ToJSON Product where
toJSON (Product image description) = object ["image" .= image,
"description" .= description]
encodeToJson :: FilePath -> IO()
encodeToJson srcName = do
let jsonName = basename srcName "json"
contents writeFile jsonName (encode Product {
image = firstLine,
description = unlines restLines
})
_ -> print ("error: invalid source file: " ++ srcName)
main = do
names wrote:
> Thank you all for the responses.
>
> Qualified imports for a script of less then a page make the code less
> readable. That is why I want to specifically import subsets of
> functions and not prefix everything with qualified imports.
>
> I've taken the code from Travis (clean up some of the useless
> pack/unpack), decided to use "NoImplicitPrelude" and then I had this:
>
> #!/usr/bin/runghc
> {-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
> import Prelude (Show, IO, (++), print, String, filter)
> import Data.List (isSuffixOf)
> import Data.Text hiding (isSuffixOf, filter)
> import Data.Text.IO
> import Control.Monad (mapM_)
>
> import qualified Data.ByteString.Lazy as BL
> import System.Directory (getDirectoryContents)
> import System.FilePath.Posix ((), FilePath, takeBaseName)
>
> import Data.Aeson
>
> data Product = Product
> { image :: Text
> , description :: Text
> } deriving Show
>
> instance ToJSON Product where
> toJSON (Product image description) = object ["image" .= image,
> "description" .= description]
>
>
> encodeToJson :: FilePath -> IO()
> encodeToJson srcName = do
> let jsonName = takeBaseName srcName "json"
> contents let contentLines = lines contents
> case contentLines of -- head is unsafe! try your code on an empty
> file
> (firstLine : restLines) -> BL.writeFile jsonName (encode Product {
> image = firstLine,
> description = unlines restLines
> })
> _ -> print ("error: invalid source file: " ++ srcName)
>
>
> main = do
> names let srcNames = filter (isSuffixOf ".src") names
> mapM_ encodeToJson srcNames
>
>
> What bugs me is that this is a really simple thing to do in any other
> language, but here I seem to be stuck between Prelude and Text and as
> a beginner Prelude is king.
>
> I tried ClassyPrelude but got stuck at not being able to get the
> result of getDirectoryContents into the ClassyPrelude version of
> mapM_. Sorry but I gave up on that.
>
> I think that given all this, the above code is as beautiful as Haskell
> can pull this off at the moment.
>
> If somebody can prove me wrong, I would love to still see it.
>
> Greetings,
>
> Bram
>
>
>
>
> On Sun, Mar 1, 2015 at 1:42 AM, Travis Cardwell
> wrote:
> > On 2015?02?28? 20:23, Bram Neijt wrote:
> >> It quickly became a collection of "import qualified" and "T.unpack,
> >> T.pack" calls that made the whole thing look ugly [1].
> >
> >> [1] Source can be read here: https://gist.github.com/
> bneijt/9bdb4b1759790a8463c9
> >
> > File paths are of type `System.FilePath.Posix.FilePath`, a type alias
> for
> > `String`. Note that this convention is also followed in `ByteString` and
> > `Text` libraries; they do not use `ByteString` or `Text` types for the
> > file paths.
> >
> > In this code, file paths are packed only to have to unpack them again
> > (twice!), which likely offsets any performance improvements of using the
> > `Text` version of `isSuffixOf`.
> >
> > Here is a version using the same style but without packing file paths:
> > https://gist.github.com/TravisCardwell/fd9981e4968e4af3751d
> >
> > I included a few other changes, which are commented in the code.
> >
> > By the way, I do not think that qualified imports are bad. I like them
> > because they provide an explicit reference to the source module of a
> function.
> >
> > Cheers,
> >
> > Travis
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From hjgtuyl at chello.nl Sun Mar 1 20:01:31 2015
From: hjgtuyl at chello.nl (Henk-Jan van Tuyl)
Date: Sun, 01 Mar 2015 21:01:31 +0100
Subject: [Haskell-cafe] Skolems!
In-Reply-To:
References:
Message-ID:
On Sat, 28 Feb 2015 18:02:02 +0100, wrote:
> But this complains about a (rigid, skolem) type (and "n" really is just
> a string):
Remind me, was skolem the one that you must not feed after midnight, or
the one that keeps mumbling "My precious"? :)
Regards,
Henk-Jan van Tuyl
--
Folding at home
What if you could share your unused computer power to help find a cure? In
just 5 minutes you can join the world's biggest networked computer and get
us closer sooner. Watch the video.
http://folding.stanford.edu/
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
From bneijt at gmail.com Sun Mar 1 21:49:01 2015
From: bneijt at gmail.com (Bram Neijt)
Date: Sun, 1 Mar 2015 22:49:01 +0100
Subject: [Haskell-cafe] What other prelude to cleanly convert text-files
into json
In-Reply-To:
References:
<54F26062.8020007@extellisys.com>
Message-ID:
Thank you!
I think that looks much better then anything I got working.
Using another Prelude looks the best in this case, but without your
help I would have never found system-fileio.
Bram
On Sun, Mar 1, 2015 at 5:52 PM, Michael Snoyman wrote:
> The trick with ClassyPrelude is to use the system-fileio package instead of
> straight directory. With that in place, you get:
>
> {-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
> import ClassyPrelude
> import Data.Aeson
> import Filesystem (listDirectory)
>
> data Product = Product
> { image :: Text
> , description :: Text
> } deriving Show
>
> instance ToJSON Product where
> toJSON (Product image description) = object ["image" .= image,
> "description" .= description]
>
>
> encodeToJson :: FilePath -> IO()
> encodeToJson srcName = do
> let jsonName = basename srcName "json"
> contents let contentLines = lines contents
> case contentLines of -- head is unsafe! try your code on an empty file
> (firstLine : restLines) -> writeFile jsonName (encode Product {
> image = firstLine,
> description = unlines restLines
> })
> _ -> print ("error: invalid source file: " ++ srcName)
>
>
> main = do
> names let srcNames = filter (flip hasExtension "src") names
> mapM_ encodeToJson srcNames
>
>
> On Sun, Mar 1, 2015 at 6:47 PM Bram Neijt wrote:
>>
>> Thank you all for the responses.
>>
>> Qualified imports for a script of less then a page make the code less
>> readable. That is why I want to specifically import subsets of
>> functions and not prefix everything with qualified imports.
>>
>> I've taken the code from Travis (clean up some of the useless
>> pack/unpack), decided to use "NoImplicitPrelude" and then I had this:
>>
>> #!/usr/bin/runghc
>> {-# LANGUAGE NoImplicitPrelude, OverloadedStrings #-}
>> import Prelude (Show, IO, (++), print, String, filter)
>> import Data.List (isSuffixOf)
>> import Data.Text hiding (isSuffixOf, filter)
>> import Data.Text.IO
>> import Control.Monad (mapM_)
>>
>> import qualified Data.ByteString.Lazy as BL
>> import System.Directory (getDirectoryContents)
>> import System.FilePath.Posix ((), FilePath, takeBaseName)
>>
>> import Data.Aeson
>>
>> data Product = Product
>> { image :: Text
>> , description :: Text
>> } deriving Show
>>
>> instance ToJSON Product where
>> toJSON (Product image description) = object ["image" .= image,
>> "description" .= description]
>>
>>
>> encodeToJson :: FilePath -> IO()
>> encodeToJson srcName = do
>> let jsonName = takeBaseName srcName "json"
>> contents > let contentLines = lines contents
>> case contentLines of -- head is unsafe! try your code on an empty
>> file
>> (firstLine : restLines) -> BL.writeFile jsonName (encode Product {
>> image = firstLine,
>> description = unlines restLines
>> })
>> _ -> print ("error: invalid source file: " ++ srcName)
>>
>>
>> main = do
>> names > let srcNames = filter (isSuffixOf ".src") names
>> mapM_ encodeToJson srcNames
>>
>>
>> What bugs me is that this is a really simple thing to do in any other
>> language, but here I seem to be stuck between Prelude and Text and as
>> a beginner Prelude is king.
>>
>> I tried ClassyPrelude but got stuck at not being able to get the
>> result of getDirectoryContents into the ClassyPrelude version of
>> mapM_. Sorry but I gave up on that.
>>
>> I think that given all this, the above code is as beautiful as Haskell
>> can pull this off at the moment.
>>
>> If somebody can prove me wrong, I would love to still see it.
>>
>> Greetings,
>>
>> Bram
>>
>>
>>
>>
>> On Sun, Mar 1, 2015 at 1:42 AM, Travis Cardwell
>> wrote:
>> > On 2015?02?28? 20:23, Bram Neijt wrote:
>> >> It quickly became a collection of "import qualified" and "T.unpack,
>> >> T.pack" calls that made the whole thing look ugly [1].
>> >
>> >> [1] Source can be read here:
>> >> https://gist.github.com/bneijt/9bdb4b1759790a8463c9
>> >
>> > File paths are of type `System.FilePath.Posix.FilePath`, a type alias
>> > for
>> > `String`. Note that this convention is also followed in `ByteString`
>> > and
>> > `Text` libraries; they do not use `ByteString` or `Text` types for the
>> > file paths.
>> >
>> > In this code, file paths are packed only to have to unpack them again
>> > (twice!), which likely offsets any performance improvements of using the
>> > `Text` version of `isSuffixOf`.
>> >
>> > Here is a version using the same style but without packing file paths:
>> > https://gist.github.com/TravisCardwell/fd9981e4968e4af3751d
>> >
>> > I included a few other changes, which are commented in the code.
>> >
>> > By the way, I do not think that qualified imports are bad. I like them
>> > because they provide an explicit reference to the source module of a
>> > function.
>> >
>> > Cheers,
>> >
>> > Travis
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From ok at cs.otago.ac.nz Sun Mar 1 23:31:29 2015
From: ok at cs.otago.ac.nz (Richard A. O'Keefe)
Date: Mon, 2 Mar 2015 12:31:29 +1300
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <54F17EFF.7010902@home.nl>
References: <54F17EFF.7010902@home.nl>
Message-ID:
On 28/02/2015, at 9:40 pm, Roelof Wobben wrote:
> I found out that for 1 item I can do this : node = Node leaf "msg 1" leaf
> And for 2 items I can do this : node = Node leaf "msg1" (Node leaf "msg2" leaf)
Your subject line says "how to make THIS work recursive(ly)" but the
body of your message does not explain what "this" is.
It looks as thought you have
data BinaryTree x
= Leaf
| Node (BinaryTree x) x (BinaryTree x)
except that you have written a variable name "leaf" instead of
a constant name "Leaf" (ok, there are no constant names, it's a constructor
name, but a constructor with no arguments is a constant).
>
> But now I wonder how I can make this work with recursion.
Well, you have to START by saying clearly what "THIS" is.
It looks as though you want
empty :: BinaryTree x
insert :: Ord x => x -> BinaryTree x -> BinaryTree x
There's only one thing you can put for empty. To make a Node
you would have to a value of type t, and you don't. So
empty = Leaf
What about insert?
You have two arguments: an x (and all you know about x values is that
they can be compared) and a BinaryTree x. It's going to have to be
a case analysis on the two possibilities for the BinaryTree:
insert v Leaf = Node Leaf v Leaf
insert v (Node lss elt gtr) = ??
Where are we doing to put v? There are three places:
lss (the set of things less than elt)
elt (the value elt)
gtr (the set of things greater than elt).
How can we tell where to put v?
Answer: by comparing v with elt:
case compare v elt of
LT -> "insert v in lss"
GT -> "insert v in gtr"
EQ -> "it's already in elt"
Convert the comments to Haskell, and we have
insert v Leaf = Node Leaf v Leaf
insert v (Node lss elt gtr) =
case compare v elt of
LT -> Node (insert v lss) elt gtr
GT -> Node lss elt (insert v gtr)
EQ -> Node lss elt gtr
We don't actually *MAKE* this function work recursively,
it just *happens* that to insert an element into a big
tree, we sometimes want to insert it into a subtree.
A first or second year data structure book would do this
in C:
typedef ???? elem;
typedef struct Node *tree;
typedef struct Node {
tree lss;
elem elt;
tree gtr;
} Node;
tree insert(elem v, tree t) {
if (t == 0) { /* leaf case */
tree n = malloc(sizeof *n);
if (n == 0) abort();
n->lss = n->gtr = 0, n->elt = elt;
return n;
} else {
if (v < t->elt) {
t->lss = insert(v, t->lss);
} else
if (t->elt < v) {
t->gtr = insert(v, t->gtr);
}
return t;
}
}
> It seems that I keep the first 2 items and change the 3th one from leaf to another node
You DO NOT CHANGE ANYTHING. Given a tree and a (possibly) new element,
you construct a NEW tree which shares most of its structure with the
old one. In C, you have to destroy the old tree to make the new one.
In Haskell, you not only don't have to, you can't.
But the basic pattern:
to insert v into t
if t is empty
return a new tree just containing v
if t is not empty
if v is less than the top element of t
insert v into the left subtree of t
if v is greater than the top element of t
insert v into the right subtree of t
if v is equal to the top element of t
there is nothing to do
does not depend on which programming language you are using.
If you are alert, you will notice a strong similarity between
the structure of the DATA (a two-way choice where one choice
is simple and the other has three parts) and the structure of
the CODE (a two-way choice where one choice is simple and
the other has three parts). This is not an accident.
>
From ok at cs.otago.ac.nz Sun Mar 1 23:49:46 2015
From: ok at cs.otago.ac.nz (Richard A. O'Keefe)
Date: Mon, 2 Mar 2015 12:49:46 +1300
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <54F1C524.4060706@home.nl>
References: <54F17EFF.7010902@home.nl>
<54F1A184.8060800@home.nl>
<54F1C524.4060706@home.nl>
Message-ID: <72CB7458-8F71-478D-BD71-CE2CE36CDA77@cs.otago.ac.nz>
On 1/03/2015, at 2:39 am, Roelof Wobben wrote:
> I tried this :
>
> insert :: LogMessage -> MessageTree -> MessageTree
> insert s =
> case words s of
> (_:_: "This is not the right format") -> MessageTree Leaf
> _ -> MessageTree Node LogMessage Leaf
This makes no sense.
You have declared that insert takes a LogMessage argument
and a MessageTree argument and returns a MessageTree result.
Then your code DOES NOT ACCEPT A MESSAGETREE ARGUMENT!
You want to have
insert logmsg msgtree =
and the case analysis should be on the message tree, not the log message.
src/LogAnalysis.hs at 38:49-38:60
> Not in scope: data constructor
> MessageTree
> src/LogAnalysis.hs at 39:49-39:60
> Not in scope: data constructor
> MessageTree
The compiler is telling you, as clearly as it knows how,
that you DO NOT HAVE ANY CONSTRUCTOR FUNCTION called "MessageTree".
The constructor functions are >> Leaf << and >> Node <
References: <54F17EFF.7010902@home.nl> <54F1A184.8060800@home.nl> <54F1C524.4060706@home.nl> <54F1FB13.3040206@home.nl>
<54F2E745.7050505@home.nl>
Message-ID: <67EA1046-476D-4D74-B543-CE21D43DF1EF@cs.otago.ac.nz>
On 1/03/2015, at 11:17 pm, Roelof Wobben wrote:
>
> Now I have to find out how I can test if the LogMessage has the text "this is not the right format" in it.
Well, the Haskell libraries include regular expression support.
At an elementary level, you can always do
is_prefix_of :: Eq x => [x] -> [x] -> Bool
is_prefix_of (x:xs) (y:ys) = x == y && is_prefix_of xs ys
is_prefix_of (x:xs) [] = False
is_prefix_of [] _ = True
is_infix_of :: Eq x => [x] -> [x] -> Bool
is_infix_of xs ys =
xs `is_prefix_of` ys || (not (null ys) && xs `is_infix_of` tail ys)
"this is not the right format" `is_infix_of` aLogMessage
But it would be better if your LogMessage were not a string
but something structured where you did not have to go looking
for that text because you KNEW where to look for it.
From kai at kzhang.org Mon Mar 2 05:37:41 2015
From: kai at kzhang.org (Kai Zhang)
Date: Sun, 1 Mar 2015 21:37:41 -0800
Subject: [Haskell-cafe] ANN: clustering-0.1.0
Message-ID:
https://hackage.haskell.org/package/clustering
This package provides optimal algorithms (O(N^2)) for hierarchical
clustering, including single linkage, complete linkage, average linkage,
weighted linkage, and Ward's method. Benchmarks of average linkage can be
found here: https://github.com/kaizhang/clustering. I hope this would be
useful in general.
Motivation of this work: I found the "hierarchical-clustering" library
cannot handle large input (>10^4) due to its suboptimal algorithms.
Best,
Kai
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From zemyla at gmail.com Mon Mar 2 06:06:31 2015
From: zemyla at gmail.com (Zemyla)
Date: Mon, 2 Mar 2015 00:06:31 -0600
Subject: [Haskell-cafe] is it possible to implement Functor for
ByteString and Text
In-Reply-To: <54F212C9.6040509@gmail.com>
References: <54F212C9.6040509@gmail.com>
Message-ID:
What I would do is hold the function to apply in the wrapper type.
import qualified Data.ByteString as BS
data ByteString' a = ByteString' (Word8 -> a) BS.ByteString
wrap :: BS.ByteString -> ByteString' Word8
wrap bs = ByteString' id bs
-- The type ensures you can only unwrap with a function Word8 -> Word8.
unwrap :: ByteString' Word8 -> ByteString
unwrap (ByteString' f bs) = BS.map f bs
-- Functor instance just concatenates the fmapped function.
instance Functor ByteString' where
fmap f (ByteString' g bs) = ByteString' (f . g) bs
-- Foldable instance just uses the fmapped function.
instance Foldable ByteString' where
foldr f z (ByteString' g bs) = BS.foldr (f . g) z bs
-- You could define foldr', foldl, etc. based on the ones in
Data.ByteString.
-- Not strictly necessary, but nice to have.
As an added benefit, this doesn't require GADTs. It probably would if you
wanted to implement Monad as well, though.
On Feb 28, 2015 1:11 PM, "silvio" wrote:
> I have recently heard that some people want to burn bridges (introducing
> Foldable and Traversable to Prelude) and I've been wondering if it was
> possible somehow allow Text and Bytestring like containers to make use
> of those functions. Something along the lines of
>
> import qualified Data.ByteString as BS
>
> newtype ByteString' a = ByteString' BS.ByteString
>
> type ByteString = ByteString' Word8
>
> instance (ByteString' a ~ ByteString' Word8) => Functor (ByteString')
> where
> fmap f (ByteString' bs) = ByteString' $ BS.map f bs
>
>
> Or if DataContexts worked as you would expect.
>
> newtype (Word8 ~ a) => ByteString' a = ByteString' BS.ByteString
>
> However I couldn't find a solution and I was just wondering if it is
> possible.
>
> P.S. Using GADTS it does actually work for Foldable, but only because it
> doesn't have to output any ByteStrings. It doesn't work for Functor for
> instance.
>
> data ByteString' a where
> ByteString' :: BS.ByteString -> ByteString' Word8
>
> type ByteString = ByteString' Word8
>
> instance Foldable ByteString' where
> foldr f ini (ByteString' bs) = BS.foldr f ini bs
>
>
> Silvio
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From r.wobben at home.nl Mon Mar 2 08:22:13 2015
From: r.wobben at home.nl (Roelof Wobben)
Date: Mon, 02 Mar 2015 09:22:13 +0100
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To:
References: <54F17EFF.7010902@home.nl>
Message-ID: <54F41DB5.1010500@home.nl>
Richard A. O'Keefe schreef op 2-3-2015 om 0:31:
> On 28/02/2015, at 9:40 pm, Roelof Wobben wrote:
>> I found out that for 1 item I can do this : node = Node leaf "msg 1" leaf
>> And for 2 items I can do this : node = Node leaf "msg1" (Node leaf "msg2" leaf)
> Your subject line says "how to make THIS work recursive(ly)" but the
> body of your message does not explain what "this" is.
>
> It looks as thought you have
>
> data BinaryTree x
> = Leaf
> | Node (BinaryTree x) x (BinaryTree x)
>
> except that you have written a variable name "leaf" instead of
> a constant name "Leaf" (ok, there are no constant names, it's a constructor
> name, but a constructor with no arguments is a constant).
>
>> But now I wonder how I can make this work with recursion.
> Well, you have to START by saying clearly what "THIS" is.
>
> It looks as though you want
>
> empty :: BinaryTree x
>
> insert :: Ord x => x -> BinaryTree x -> BinaryTree x
>
> There's only one thing you can put for empty. To make a Node
> you would have to a value of type t, and you don't. So
>
> empty = Leaf
>
> What about insert?
> You have two arguments: an x (and all you know about x values is that
> they can be compared) and a BinaryTree x. It's going to have to be
> a case analysis on the two possibilities for the BinaryTree:
>
> insert v Leaf = Node Leaf v Leaf
> insert v (Node lss elt gtr) = ??
>
> Where are we doing to put v? There are three places:
> lss (the set of things less than elt)
> elt (the value elt)
> gtr (the set of things greater than elt).
> How can we tell where to put v?
>
> Answer: by comparing v with elt:
>
> case compare v elt of
> LT -> "insert v in lss"
> GT -> "insert v in gtr"
> EQ -> "it's already in elt"
>
> Convert the comments to Haskell, and we have
>
> insert v Leaf = Node Leaf v Leaf
> insert v (Node lss elt gtr) =
> case compare v elt of
> LT -> Node (insert v lss) elt gtr
> GT -> Node lss elt (insert v gtr)
> EQ -> Node lss elt gtr
>
> We don't actually *MAKE* this function work recursively,
> it just *happens* that to insert an element into a big
> tree, we sometimes want to insert it into a subtree.
>
> A first or second year data structure book would do this
> in C:
>
> typedef ???? elem;
>
> typedef struct Node *tree;
> typedef struct Node {
> tree lss;
> elem elt;
> tree gtr;
> } Node;
>
> tree insert(elem v, tree t) {
> if (t == 0) { /* leaf case */
> tree n = malloc(sizeof *n);
> if (n == 0) abort();
> n->lss = n->gtr = 0, n->elt = elt;
> return n;
> } else {
> if (v < t->elt) {
> t->lss = insert(v, t->lss);
> } else
> if (t->elt < v) {
> t->gtr = insert(v, t->gtr);
> }
> return t;
> }
> }
>
>
>> It seems that I keep the first 2 items and change the 3th one from leaf to another node
> You DO NOT CHANGE ANYTHING. Given a tree and a (possibly) new element,
> you construct a NEW tree which shares most of its structure with the
> old one. In C, you have to destroy the old tree to make the new one.
> In Haskell, you not only don't have to, you can't.
>
> But the basic pattern:
>
> to insert v into t
> if t is empty
> return a new tree just containing v
> if t is not empty
> if v is less than the top element of t
> insert v into the left subtree of t
> if v is greater than the top element of t
> insert v into the right subtree of t
> if v is equal to the top element of t
> there is nothing to do
>
> does not depend on which programming language you are using.
>
> If you are alert, you will notice a strong similarity between
> the structure of the DATA (a two-way choice where one choice
> is simple and the other has three parts) and the structure of
> the CODE (a two-way choice where one choice is simple and
> the other has three parts). This is not an accident.
>
>
Thanks for the explanation.
Roelof
From r.wobben at home.nl Mon Mar 2 08:23:09 2015
From: r.wobben at home.nl (Roelof Wobben)
Date: Mon, 02 Mar 2015 09:23:09 +0100
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <72CB7458-8F71-478D-BD71-CE2CE36CDA77@cs.otago.ac.nz>
References: <54F17EFF.7010902@home.nl>
<54F1A184.8060800@home.nl>
<54F1C524.4060706@home.nl>
<72CB7458-8F71-478D-BD71-CE2CE36CDA77@cs.otago.ac.nz>
Message-ID: <54F41DED.9030802@home.nl>
Richard A. O'Keefe schreef op 2-3-2015 om 0:49:
> On 1/03/2015, at 2:39 am, Roelof Wobben wrote:
>
>> I tried this :
>>
>> insert :: LogMessage -> MessageTree -> MessageTree
>> insert s =
>> case words s of
>> (_:_: "This is not the right format") -> MessageTree Leaf
>> _ -> MessageTree Node LogMessage Leaf
> This makes no sense.
> You have declared that insert takes a LogMessage argument
> and a MessageTree argument and returns a MessageTree result.
>
> Then your code DOES NOT ACCEPT A MESSAGETREE ARGUMENT!
>
> You want to have
>
> insert logmsg msgtree =
>
> and the case analysis should be on the message tree, not the log message.
>
> src/LogAnalysis.hs at 38:49-38:60
>> Not in scope: data constructor
>> MessageTree
>> src/LogAnalysis.hs at 39:49-39:60
>> Not in scope: data constructor
>> MessageTree
> The compiler is telling you, as clearly as it knows how,
> that you DO NOT HAVE ANY CONSTRUCTOR FUNCTION called "MessageTree".
> The constructor functions are >> Leaf << and >> Node < MessageTree is a *TYPE NAME*.
>
>
> I am about to be offensive.
> I do not want to be offensive.
> I want to be helpful.
> I believe this question needs to be asked.
> But there is a real risk that I will offend you.
>
> Here goes.
>
> Is there *any* programming language you know how to use?
>
> The reason that I ask is that the problems you keep having
> aren't really Haskell problems. They are general programming
> problems:
> - declaring a name as one kind of thing
> and using it as if it were another
> - declaring a function (like 'insert' or 'Node')
> to have n arguments but trying to define or call
> it with m arguments where m ~= n.
> - not starting with a description of your problem
> - not having a clue what to do when the compiler tells
> you something. (It's OK not to understand a
> compiler message. But you should get *some* clue
> from it, like where exactly to look, and you should
> be able to try to vary the program to see how the
> message changes.)
>
> I honestly feel that the difficulties you are reporting here
> aren't really Haskell difficulties, just as the difficulties
> you were reporting in the Erlang mailing list weren't really
> Erlang difficulties, but in both cases, something much more
> fundamental.
>
> To restate my possibly offensive question again:
>
> Have you ever had a course of instruction in the use of
> any programming language face to face with a competent
> teacher?
>
> Again, I'm trying to be helpful here. If you run into a
> problem and can get help within *minutes*, and have someone
> sit down beside you at the keyboard and *show* you how to
> find out what a compiler message might mean and what to do
> about it, you can learn very quickly. If you have to wait
> hours for responses, you are obviously going to learn much
> more slowly.
>
> I sometimes ask my students: "What's the point of coming here?
> Why not just buy a textbook?" Sadly, they sometimes do not
> know the answer. It's "You can ask ME questions, and each other."
>
> It is clear that you are working at trying to learn Haskell.
> It is SMART of you to ask questions.
> It's just that there are these really basic issues where I
> think you could learn a lot faster with face-to-face help.
>
>
>
I have not done any face to face courses.
Programming is a hobby for me.
Roelof
From r.wobben at home.nl Mon Mar 2 08:27:08 2015
From: r.wobben at home.nl (Roelof Wobben)
Date: Mon, 02 Mar 2015 09:27:08 +0100
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <67EA1046-476D-4D74-B543-CE21D43DF1EF@cs.otago.ac.nz>
References: <54F17EFF.7010902@home.nl> <54F1A184.8060800@home.nl> <54F1C524.4060706@home.nl> <54F1FB13.3040206@home.nl>
<54F2E745.7050505@home.nl>
<67EA1046-476D-4D74-B543-CE21D43DF1EF@cs.otago.ac.nz>
Message-ID: <54F41EDC.3090506@home.nl>
Richard A. O'Keefe schreef op 2-3-2015 om 0:59:
> On 1/03/2015, at 11:17 pm, Roelof Wobben wrote:
>> Now I have to find out how I can test if the LogMessage has the text "this is not the right format" in it.
>
> Well, the Haskell libraries include regular expression support.
> At an elementary level, you can always do
>
> is_prefix_of :: Eq x => [x] -> [x] -> Bool
> is_prefix_of (x:xs) (y:ys) = x == y && is_prefix_of xs ys
> is_prefix_of (x:xs) [] = False
> is_prefix_of [] _ = True
>
>
> is_infix_of :: Eq x => [x] -> [x] -> Bool
>
> is_infix_of xs ys =
> xs `is_prefix_of` ys || (not (null ys) && xs `is_infix_of` tail ys)
>
>
> "this is not the right format" `is_infix_of` aLogMessage
>
> But it would be better if your LogMessage were not a string
> but something structured where you did not have to go looking
> for that text because you KNEW where to look for it.
>
>
I know where to look.
A LogMessage looks like this :
data LogMessage = LogMessage MessageType TimeStamp String
| Unknown String
deriving (Show, Eq)
So if it's Unknown with a string then it will not be inserted into the
MessageTree
The only thing I have to find out if LogMessage contains this.
Roelof
From ok at cs.otago.ac.nz Mon Mar 2 09:57:42 2015
From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz)
Date: Mon, 2 Mar 2015 22:57:42 +1300
Subject: [Haskell-cafe] how to make this work recursive ?
In-Reply-To: <54F41EDC.3090506@home.nl>
References: <54F17EFF.7010902@home.nl>
<54F1A184.8060800@home.nl>
<54F1C524.4060706@home.nl>
<54F1FB13.3040206@home.nl>
<54F2E745.7050505@home.nl>
<67EA1046-476D-4D74-B543-CE21D43DF1EF@cs.otago.ac.nz>
<54F41EDC.3090506@home.nl>
Message-ID: <31f763ef76effa884626a50f7def1de4.squirrel@chasm.otago.ac.nz>
You are still not being clear.
You have
data LogMessage
= LogMessage MessageType TimeStamp String
| Unknown String
deriving (Show, Eq)
> So if it's Unknown with a string then it will not be inserted into the
> MessageTree
> The only thing I have to find out if LogMessage contains this.
Question 1.
Your description seems contradictory.
The first sentence is talking about the Unknown case.
The second sentence appears to be talking about the other
case.
Do you mean
should_discard (LogMessage _ _ _) = False
should_discard (Unknown s) = ...s contains magic...
or
should_discard (LogMessage _ _ s) = ...s contains magic...
should_discard (Unknown _) = False
or
should_discard (LogMessage Error _ s) = ...s contains magic...
should_discard _ = False
or what?
Question 2.
What do you mean by "contains"?
Do you mean
- is exactly equal to
- is equal to ignoring leading and trailing white space
and treating runs of white space as single spaces
- is equal to ignoring alphabetic case
- equality up to some other predicate
- contains a substring equal to
(this is what I first thought you meant)
- contains a substring equivalent to up to some predicate
or something else?
In short, before you can ask how to do "this",
you have to say in plain words what "this" IS.
The _answer_ will be concerned with Haskell,
but _the way you should ask such questions_ is not.
In any programming language, whatever code you write is going to
have *some* precise meaning. The industry as a whole has a huge
problem with differences between what people *want* their
program to mean/do and what it *does* mean/do. We haven't a hope
of detecting such problems in good time if we aren't clear about
what it is that we want.
Here's another tip. Some people find it helps.
Before you start to write a function, just write a stub (others
have shown you examples, using 'undefined' as the body; that's
a stub), and write test cases that call it. This may help to
clarify your ideas about what you want the function to do with
_those_ examples, and thereby about others.
From alexander at plaimi.net Mon Mar 2 11:18:43 2015
From: alexander at plaimi.net (Alexander Berntsen)
Date: Mon, 02 Mar 2015 12:18:43 +0100
Subject: [Haskell-cafe] Would you use frozen-base
In-Reply-To:
References: <1424957771.1948.49.camel@joachim-breitner.de>
Message-ID: <54F44713.3000701@plaimi.net>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 26/02/15 20:50, Bardur Arantsson wrote:
> The proper solution to this problem (as with so many things) is
> another layer of indirection, namely a proper way to separate API
> and implementation. (Aka "Backpack" or similar.)
I'd prefer to see work going into Backpack or similar rather than
frozen-base. I share the concerns expressed by Bardur and David. (Of
course I don't want to discourage work on frozen-base altogether, as
I'm sure it could be an interesting experiment if nothing more.)
- --
Alexander
alexander at plaimi.net
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iF4EAREIAAYFAlT0RxEACgkQRtClrXBQc7VZPQD/f/NxeQh4uo2HP/v+oJJ/bMOA
T1EGkF1LbBM0/J1Ykk0A/0rosssIfCCYAFuOZgI2BGMei0CSKPt23zweBrqYkfB+
=OymM
-----END PGP SIGNATURE-----
From sean at functionaljobs.com Mon Mar 2 17:00:01 2015
From: sean at functionaljobs.com (Functional Jobs)
Date: Mon, 2 Mar 2015 12:00:01 -0500
Subject: [Haskell-cafe] New Functional Programming Job Opportunities
Message-ID: <54f4971337565@functionaljobs.com>
Here are some functional programming job opportunities that were posted
recently:
Senior Software Engineer at McGraw-Hill Education
http://functionaljobs.com/jobs/8787-senior-software-engineer-at-mcgraw-hill-education
Engineering Manager (OCaml or Haskell under Linux) at FireEye
http://functionaljobs.com/jobs/8786-engineering-manager-ocaml-or-haskell-under-linux-at-fireeye
Cheers,
Sean Murphy
FunctionalJobs.com
From eir at cis.upenn.edu Mon Mar 2 18:12:33 2015
From: eir at cis.upenn.edu (Richard Eisenberg)
Date: Mon, 2 Mar 2015 13:12:33 -0500
Subject: [Haskell-cafe] Skolems!
In-Reply-To:
References:
Message-ID: <4CD633E4-0DE7-4D26-87DC-870B588EE743@cis.upenn.edu>
This is admittedly a dark corner of the inference algorithm, but perhaps these examples can shed some light. Post a bug report!
Thanks for creating nice, small examples.
Richard
PS: I offer no strong guarantees that you've found bugs here... but in any case, posting a bug report gets more serious attention than a Haskell-cafe post.
On Feb 27, 2015, at 1:23 PM, "evan at evan-borden.com" wrote:
> An extension of the message Tom sent a little while back, we've discovered a more in depth example of this possible GHC bug. It is exacerbated by GADTs, but can be fixed with NoMonoLocalBinds. Without GADTs and just leveraging ExistentialQuanitification it works fine. We've included a pretty exhaustive set of examples.
>
> {-# LANGUAGE ExistentialQuantification, GADTs #-}
>
> {- removing MonoLocalBinds fixes all of these errors
> {-# LANGUAGE ExistentialQuantification, GADTs, NoMonoLocalBinds #-}
> -}
>
> module PossibleGHCBug where
>
> data SumType = SumFoo | SumBar
>
> class SomeClass a where
> someType :: a -> SumType
>
> data SomeExistential = forall a. SomeClass a => SomeExistential a
>
> noError :: String -> [SomeExistential] -> String
> noError n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> "asdf"
>
> noError2 :: String -> [SomeExistential] -> String
> noError2 n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c :: SumType -> String
> c p = case p of
> SumFoo -> "foo"
> _ -> "asdf" ++ n
>
> noError3 :: String -> [SomeExistential] -> String
> noError3 n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d :: SomeClass a => a -> String
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> "asdf" ++ n
>
>
> partialTypedError :: String -> [SomeExistential] -> String
> partialTypedError n st = n ++ concatMap cname st
> where cname :: SomeExistential -> String
> cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> "asdf" ++ n
>
> fullError :: String -> [SomeExistential] -> String
> fullError n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> "asdf" ++ n
>
> justNError :: String -> [SomeExistential] -> String
> justNError n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> n
>
> ignoreNError :: String -> [SomeExistential] -> String
> ignoreNError n st = n ++ concatMap cname st
> where cname (SomeExistential p) = d p
>
> d p = c $ someType p
>
> c p = case p of
> SumFoo -> "foo"
> _ -> fst ("foo", n)
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From evan at evanrutledgeborden.dreamhosters.com Mon Mar 2 18:49:26 2015
From: evan at evanrutledgeborden.dreamhosters.com (evan@evan-borden.com)
Date: Mon, 2 Mar 2015 13:49:26 -0500
Subject: [Haskell-cafe] Skolems!
In-Reply-To: <4CD633E4-0DE7-4D26-87DC-870B588EE743@cis.upenn.edu>
References:
<4CD633E4-0DE7-4D26-87DC-870B588EE743@cis.upenn.edu>
Message-ID:
Thanks Richard, will do.
On Mon, Mar 2, 2015 at 1:12 PM, Richard Eisenberg wrote:
> This is admittedly a dark corner of the inference algorithm, but perhaps
> these examples can shed some light. Post a bug report!
>
> Thanks for creating nice, small examples.
>
> Richard
>
> PS: I offer no strong guarantees that you've found bugs here... but in any
> case, posting a bug report gets more serious attention than a Haskell-cafe
> post.
>
> On Feb 27, 2015, at 1:23 PM, "evan at evan-borden.com" <
> evan at evanrutledgeborden.dreamhosters.com> wrote:
>
> > An extension of the message Tom sent a little while back, we've
> discovered a more in depth example of this possible GHC bug. It is
> exacerbated by GADTs, but can be fixed with NoMonoLocalBinds. Without GADTs
> and just leveraging ExistentialQuanitification it works fine. We've
> included a pretty exhaustive set of examples.
> >
> > {-# LANGUAGE ExistentialQuantification, GADTs #-}
> >
> > {- removing MonoLocalBinds fixes all of these errors
> > {-# LANGUAGE ExistentialQuantification, GADTs, NoMonoLocalBinds #-}
> > -}
> >
> > module PossibleGHCBug where
> >
> > data SumType = SumFoo | SumBar
> >
> > class SomeClass a where
> > someType :: a -> SumType
> >
> > data SomeExistential = forall a. SomeClass a => SomeExistential a
> >
> > noError :: String -> [SomeExistential] -> String
> > noError n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> "asdf"
> >
> > noError2 :: String -> [SomeExistential] -> String
> > noError2 n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c :: SumType -> String
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> "asdf" ++ n
> >
> > noError3 :: String -> [SomeExistential] -> String
> > noError3 n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d :: SomeClass a => a -> String
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> "asdf" ++ n
> >
> >
> > partialTypedError :: String -> [SomeExistential] -> String
> > partialTypedError n st = n ++ concatMap cname st
> > where cname :: SomeExistential -> String
> > cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> "asdf" ++ n
> >
> > fullError :: String -> [SomeExistential] -> String
> > fullError n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> "asdf" ++ n
> >
> > justNError :: String -> [SomeExistential] -> String
> > justNError n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> n
> >
> > ignoreNError :: String -> [SomeExistential] -> String
> > ignoreNError n st = n ++ concatMap cname st
> > where cname (SomeExistential p) = d p
> >
> > d p = c $ someType p
> >
> > c p = case p of
> > SumFoo -> "foo"
> > _ -> fst ("foo", n)
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From evan at evanrutledgeborden.dreamhosters.com Mon Mar 2 18:56:09 2015
From: evan at evanrutledgeborden.dreamhosters.com (evan@evan-borden.com)
Date: Mon, 2 Mar 2015 13:56:09 -0500
Subject: [Haskell-cafe] Skolems!
In-Reply-To:
References:
<4CD633E4-0DE7-4D26-87DC-870B588EE743@cis.upenn.edu>
Message-ID:
A quick clarification. It s trac still the location to submit bugs or is
Phabricator more appropriate?
On Mon, Mar 2, 2015 at 1:49 PM, evan at evan-borden.com <
evan at evanrutledgeborden.dreamhosters.com> wrote:
> Thanks Richard, will do.
>
> On Mon, Mar 2, 2015 at 1:12 PM, Richard Eisenberg
> wrote:
>
>> This is admittedly a dark corner of the inference algorithm, but perhaps
>> these examples can shed some light. Post a bug report!
>>
>> Thanks for creating nice, small examples.
>>
>> Richard
>>
>> PS: I offer no strong guarantees that you've found bugs here... but in
>> any case, posting a bug report gets more serious attention than a
>> Haskell-cafe post.
>>
>> On Feb 27, 2015, at 1:23 PM, "evan at evan-borden.com" <
>> evan at evanrutledgeborden.dreamhosters.com> wrote:
>>
>> > An extension of the message Tom sent a little while back, we've
>> discovered a more in depth example of this possible GHC bug. It is
>> exacerbated by GADTs, but can be fixed with NoMonoLocalBinds. Without GADTs
>> and just leveraging ExistentialQuanitification it works fine. We've
>> included a pretty exhaustive set of examples.
>> >
>> > {-# LANGUAGE ExistentialQuantification, GADTs #-}
>> >
>> > {- removing MonoLocalBinds fixes all of these errors
>> > {-# LANGUAGE ExistentialQuantification, GADTs, NoMonoLocalBinds #-}
>> > -}
>> >
>> > module PossibleGHCBug where
>> >
>> > data SumType = SumFoo | SumBar
>> >
>> > class SomeClass a where
>> > someType :: a -> SumType
>> >
>> > data SomeExistential = forall a. SomeClass a => SomeExistential a
>> >
>> > noError :: String -> [SomeExistential] -> String
>> > noError n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> "asdf"
>> >
>> > noError2 :: String -> [SomeExistential] -> String
>> > noError2 n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c :: SumType -> String
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> "asdf" ++ n
>> >
>> > noError3 :: String -> [SomeExistential] -> String
>> > noError3 n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d :: SomeClass a => a -> String
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> "asdf" ++ n
>> >
>> >
>> > partialTypedError :: String -> [SomeExistential] -> String
>> > partialTypedError n st = n ++ concatMap cname st
>> > where cname :: SomeExistential -> String
>> > cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> "asdf" ++ n
>> >
>> > fullError :: String -> [SomeExistential] -> String
>> > fullError n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> "asdf" ++ n
>> >
>> > justNError :: String -> [SomeExistential] -> String
>> > justNError n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> n
>> >
>> > ignoreNError :: String -> [SomeExistential] -> String
>> > ignoreNError n st = n ++ concatMap cname st
>> > where cname (SomeExistential p) = d p
>> >
>> > d p = c $ someType p
>> >
>> > c p = case p of
>> > SumFoo -> "foo"
>> > _ -> fst ("foo", n)
>> >
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From jan.stolarek at p.lodz.pl Mon Mar 2 19:02:26 2015
From: jan.stolarek at p.lodz.pl (Jan Stolarek)
Date: Mon, 2 Mar 2015 20:02:26 +0100
Subject: [Haskell-cafe] Skolems!
In-Reply-To:
References:
Message-ID: <201503022002.26378.jan.stolarek@p.lodz.pl>
> A quick clarification. It s trac still the location to submit bugs or is
> Phabricator more appropriate?
Trac is still the place to submit bugs. Once a bug-fix is ready we use Phabricator to code-review
the patch.
Janek
>
> On Mon, Mar 2, 2015 at 1:49 PM, evan at evan-borden.com <
>
> evan at evanrutledgeborden.dreamhosters.com> wrote:
> > Thanks Richard, will do.
> >
> > On Mon, Mar 2, 2015 at 1:12 PM, Richard Eisenberg
> >
> > wrote:
> >> This is admittedly a dark corner of the inference algorithm, but perhaps
> >> these examples can shed some light. Post a bug report!
> >>
> >> Thanks for creating nice, small examples.
> >>
> >> Richard
> >>
> >> PS: I offer no strong guarantees that you've found bugs here... but in
> >> any case, posting a bug report gets more serious attention than a
> >> Haskell-cafe post.
> >>
> >> On Feb 27, 2015, at 1:23 PM, "evan at evan-borden.com" <
> >>
> >> evan at evanrutledgeborden.dreamhosters.com> wrote:
> >> > An extension of the message Tom sent a little while back, we've
> >>
> >> discovered a more in depth example of this possible GHC bug. It is
> >> exacerbated by GADTs, but can be fixed with NoMonoLocalBinds. Without
> >> GADTs and just leveraging ExistentialQuanitification it works fine.
> >> We've included a pretty exhaustive set of examples.
> >>
> >> > {-# LANGUAGE ExistentialQuantification, GADTs #-}
> >> >
> >> > {- removing MonoLocalBinds fixes all of these errors
> >> > {-# LANGUAGE ExistentialQuantification, GADTs, NoMonoLocalBinds #-}
> >> > -}
> >> >
> >> > module PossibleGHCBug where
> >> >
> >> > data SumType = SumFoo | SumBar
> >> >
> >> > class SomeClass a where
> >> > someType :: a -> SumType
> >> >
> >> > data SomeExistential = forall a. SomeClass a => SomeExistential a
> >> >
> >> > noError :: String -> [SomeExistential] -> String
> >> > noError n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> "asdf"
> >> >
> >> > noError2 :: String -> [SomeExistential] -> String
> >> > noError2 n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c :: SumType -> String
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> "asdf" ++ n
> >> >
> >> > noError3 :: String -> [SomeExistential] -> String
> >> > noError3 n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d :: SomeClass a => a -> String
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> "asdf" ++ n
> >> >
> >> >
> >> > partialTypedError :: String -> [SomeExistential] -> String
> >> > partialTypedError n st = n ++ concatMap cname st
> >> > where cname :: SomeExistential -> String
> >> > cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> "asdf" ++ n
> >> >
> >> > fullError :: String -> [SomeExistential] -> String
> >> > fullError n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> "asdf" ++ n
> >> >
> >> > justNError :: String -> [SomeExistential] -> String
> >> > justNError n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> n
> >> >
> >> > ignoreNError :: String -> [SomeExistential] -> String
> >> > ignoreNError n st = n ++ concatMap cname st
> >> > where cname (SomeExistential p) = d p
> >> >
> >> > d p = c $ someType p
> >> >
> >> > c p = case p of
> >> > SumFoo -> "foo"
> >> > _ -> fst ("foo", n)
> >> >
> >> >
> >> > _______________________________________________
> >> > Haskell-Cafe mailing list
> >> > Haskell-Cafe at haskell.org
> >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
---
Politechnika ??dzka
Lodz University of Technology
Tre?? tej wiadomo?ci zawiera informacje przeznaczone tylko dla adresata.
Je?eli nie jeste?cie Pa?stwo jej adresatem, b?d? otrzymali?cie j? przez pomy?k?
prosimy o powiadomienie o tym nadawcy oraz trwa?e jej usuni?cie.
This email contains information intended solely for the use of the individual to whom it is addressed.
If you are not the intended recipient or if you have received this message in error,
please notify the sender and delete it from your system.
From mike at izbicki.me Mon Mar 2 21:14:26 2015
From: mike at izbicki.me (Mike Izbicki)
Date: Mon, 2 Mar 2015 13:14:26 -0800
Subject: [Haskell-cafe] A Proposed Law for Foldable?
In-Reply-To:
References:
<06e128af-0094-47d0-b780-065f939adc3d@googlegroups.com>
Message-ID:
I'd like to throw another law into the ring that is simple and
satisfies the issues raised by David Feuer. Using the following
definitions:
> class Foldable f where
> length :: f a -> Int
> foldMap :: (a -> b) -> f a -> b
>
> disjoint :: (Monoid (f a), Foldable f) => f a -> f a -> Bool
> disjoint f1 f2 = length f1 + length f2 == length (f1 `mappend` f2)
The law is:
> disjoint f1 f2 ==> foldMap f f1 + foldMap f f2 == foldMap f (f1 `mappend` f2)
The main advantage of the law is that it forces foldMap to consider
"every element" of the container, where "every element" is very
loosely defined. The Foldable instance that considers only the first
element in a list breaks the law. But David Feuer's Team/IP example
can be made to work with the law.
The inspiration for the law is to treat the Foldable class as a
generalization of the Lebesgue integral. If you're familiar with
measure theory, foldMap over a set of numbers "should be" the same as
integrating over the set using the discrete measure. The generalized
definition of disjoint to let us "integrate" over containers other
than sets. (For example, every list is disjoint to every other list,
but every set is not disjoint to every other set.)
On Sat, Feb 28, 2015 at 9:59 AM, Edward Kmett wrote:
> The Foldable/Monoid constraints are unrelated in behavior, so not
> necessarily.
>
> Why?
>
> At first blush you might think you'd get there via the free theorems, but
> Monoid is only on *, so you can use the inclusion of the argument in the
> Monoid instance to incur further constraints.
>
> newtype Foo a = Foo a deriving (Monoid, Foldable)
>
> now Foo has
>
> instance Foldable Foo
> instance Monoid m => Monoid (Foo m)
>
> it lifts the Monoid to the element inside, but if you fold it you get the
> single value contained inside of it, not mempty.
>
> Now if you want to upgrade this approach all the way to Alternative, rather
> than Monoid then the free theorem arguments start getting teeth.
>
> foldMap f empty = mempty
>
> should then (almost?) hold. I say almost because you might be able to have
> empty be an infinitely large tree which never gets down to values somehow,
> in which case that law would require deciding an infinite amount of work. I
> haven't sat down to prove if the latter is impossible, so I characterize it
> as at least plausible.
>
> -Edward
>
> On Fri, Feb 27, 2015 at 6:00 PM, Daniel D?az wrote:
>>
>> Hi,
>>
>> Sorry for the slight derail, but I wanted to ask the following doubt: if a
>> Foldable type also happens to be a Monoid (say, like Set) does that
>> automatically imply that toList mempty = [] ?
>>
>> On Friday, February 27, 2015 at 8:18:05 PM UTC+1, Gershom B wrote:
>>>
>>> On February 27, 2015 at 1:39:10 AM, David Feuer (david... at gmail.com)
>>> wrote:
>>> > I am still struggling to understand why you want this to be a law for
>>> > Foldable. It seems an interesting property of some Foldable instances,
>>> > but, unlike Edward Kmett's proposed monoid morphism law, it's not
>>> > clear to me how you can use this low to prove useful properties of
>>> > programs. Could you explain?
>>>
>>> I think there are a number of purposes for laws. Some can be thought of
>>> as "suggested rewrite rules" -- and the monoid morphism law is one such, as
>>> are many related free approaches.
>>>
>>> Note that the monoid morphism law that Edward provides is _not_ a
>>> "proposed" law -- it is an "almost free theorem" -- given a monoid morphism,
>>> it follows for free for any Foldable. There is no possible foldable instance
>>> that can violate this law, assuming you have an actual monoid morphism.
>>>
>>> So Edward may have proposed adding it to the documentation (which makes
>>> sense to me) -- but it provides absolutely no guidance or constraints as to
>>> what an "allowable" instance of Foldable is or is not.
>>>
>>> But there are other reasons for laws than just to provide rewrite rules,
>>> even though it is often desirable to express laws in such terms. Consider
>>> the first Functor law for example -- fmap id === id. Now clearly we can use
>>> it to go eliminate a bunch of "fmap id" calls in our program, should we have
>>> had them. But when would that ever be the case? Instead, the law is
>>> important because it _restricts_ the range of allowable instances -- and so
>>> if you know you have a data type, and you know it has a functor instance,
>>> you then know what that functor instance must do, without looking at the
>>> source code.
>>>
>>>
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
From fr33domlover at riseup.net Mon Mar 2 21:36:39 2015
From: fr33domlover at riseup.net (fr33domlover)
Date: Mon, 2 Mar 2015 23:36:39 +0200
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
Message-ID:
On 2015-02-28
Mike Meyer wrote:
>
> There are open source projects that are systematically excising GPL'ed
> software because of the problems it shares with ShareAlike licenses. Should
> we disallow the GPL because some people have problems with it?
>
> Making Hackage better to help users sort out which licenses they are
> willing to accept in their project - which I personally would like to do on
> a project-by-project basis! - is a solution to these problems. Restricting
> the licenses that are acceptable on Hackage to meet some arbitrary set of
> criteria is a knee-jerk.
The restrictions aren't arbitrary at all. They're based on ethics. On Software
freedom. But sure, a package with invalid license tagging should instantly
become unavailable.
Here's a suggestion: We can talk about this forever, because there seem to be
no official guidelines to really discuss. Why don't we put clear guidelines at
hackage.haskell.org ? If these guidelines would be "proprietary software
allowed", then there's a point to discuss. But if the guideline requires
certain tagging - currently all the license tags except all-rights-reserved are
free software licenses - maybe the problem is already solved.
Who maintains the community hackage instance and the guidelines? Just to
make sure these people are aware of this discussion.
---
fr33domlover
GPG key ID: 63E5E57D (size: 4096)
GPG key fingerprint: 6FEE C222 7323 EF85 A49D 5487 5252 C5C8 63E5 E57D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL:
From mwm at mired.org Mon Mar 2 22:27:53 2015
From: mwm at mired.org (Mike Meyer)
Date: Mon, 2 Mar 2015 16:27:53 -0600
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To: <54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Mon, Mar 2, 2015 at 3:36 PM, fr33domlover
wrote:
> On 2015-02-28
> Mike Meyer wrote:
>
> >
> > There are open source projects that are systematically excising GPL'ed
> > software because of the problems it shares with ShareAlike licenses.
> Should
> > we disallow the GPL because some people have problems with it?
> >
> > Making Hackage better to help users sort out which licenses they are
> > willing to accept in their project - which I personally would like to do
> on
> > a project-by-project basis! - is a solution to these problems.
> Restricting
> > the licenses that are acceptable on Hackage to meet some arbitrary set of
> > criteria is a knee-jerk.
> The restrictions aren't arbitrary at all. They're based on ethics. On
> Software
> freedom.
>
Until you've got an objective set of ethics - or a definition of "software
freedom" - that everyone accepts, that's just a long-winded way of saying
"arbitrary".
Here's a suggestion: We can talk about this forever, because there seem to
> be
> no official guidelines to really discuss. Why don't we put clear
> guidelines at
> hackage.haskell.org ? If these guidelines would be "proprietary software
> allowed", then there's a point to discuss. But if the guideline requires
> certain tagging - currently all the license tags except
> all-rights-reserved are
> free software licenses - maybe the problem is already solved.
>
Not quite. "OtherLicense" is an accepted license tag, and I take it to mean
I can use any license I want. If you're going to place a restriction on the
license types beyond "use one of our tags" (and if you disallow the
otherLicense tag, then I'd say that's an arbitrary restriction), then you
should either define the terms in it, or choose terms that are well
defined. "free software" is so ill defined that gnu.org has to explain what
they mean by "free software" (https://www.gnu.org/philosophy/free-sw.html).
They even point out that there are open source software licenses that don't
meet their definition of free (
https://www.gnu.org/philosophy/open-source-misses-the-point.html). Their
definition of proprietary as "not free" makes software licensed under such
licenses proprietary, though that's certainly not common usage.
So just saying "only free software licenses" or "no proprietary software"
would make matters worse, not better, because those terms have multiple
meanings in common use. And that makes them not only arbitrary, but vague.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From aditya.siram at gmail.com Tue Mar 3 00:13:31 2015
From: aditya.siram at gmail.com (aditya siram)
Date: Mon, 2 Mar 2015 18:13:31 -0600
Subject: [Haskell-cafe] C2HS parse error on Windows ...
Message-ID:
Hi all,
c2hs runs into the following error on all of my .chs files, but only on
Windows:
c:\\program files\\haskell
platform\\2014.2.0.0\\mingw\\bin\\../lib/gcc/x86_64-w64-mingw32/4.6.3/../../../../x86_64-w64-mingw32/include/stddef.h:20:
(column 11)
[ERROR] >>> Syntax error !
The symbol `__attribute__' does not fit here.
My c2hs version is:
C->Haskell Compiler, version 0.23.1 Snowbounder, 31 Oct 2014
build platform is "x86_64-mingw32" <1, True, True, 1>
This is the command being run:
"c:\Users\deech\AppData\Roaming\cabal\bin\c2hs.exe"
"--cpp=c:\Program Files\Haskell Platform\2014.2.0.0\mingw\bin\gcc.exe"
"--cppopts=-E" "--cppopts=-D__GLASGOW_HASKELL__=708"
"--cppopts=-Dmingw32_BUILD_OS=1"
"--cppopts=-Dx86_64_BUILD_ARCH=1"
"--cppopts=-Dmingw32_HOST_OS=1"
"--cppopts=-Dx86_64_HOST_ARCH=1"
"--cppopts=-I./c-src"
"--cppopts=-I./"
"--cppopts=-IC:/MinGW/include"
"--cppopts=-IC:\Users\deech\Downloads\fltkhs-0.1.0.1/c-src"
"--cppopts=-IC:\Users\deech\Downloads\fltkhs-0.1.0.1"
"--include=dist\build"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\process-1.2.0.0\include"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\directory-1.2.1.0\include"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\time-1.4.2\include"
"--cppopts=-IC:\ProgramFiles\Haskell
Platform\2014.2.0.0\lib\Win32-2.3.0.2\include"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\bytestring-0.10.4.0\include"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\base-4.7.0.1\include"
"--cppopts=-IC:\Program Files\Haskell
Platform\2014.2.0.0\lib\integer-gmp-0.5.1.0\include"
"--cppopts=-IC:\Program Files\Haskell Platform\2014.2.0.0\lib/include"
"--output-dir=dist\build"
"--output=Graphics\UI\FLTK\LowLevel\HorValueSlider.hs"
"src\Graphics\UI\FLTK\LowLevel\HorValueSlider.chs"
A little Googling turned up this thread:
http://haskell.1045720.n5.nabble.com/BUG-string-h-FC4-x86-64-td3196369.html
which suggested I pass -D__attribute__(A)= to c2hs's opts. I tried it and
it led to other errors. I didn't pursue any further because it's an old
thread. I'm not sure what stddef.h is and I'm unfamiliar with Windows.
Any help is appreciated.
Thanks!
-deech
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From mike at proclivis.com Tue Mar 3 06:05:00 2015
From: mike at proclivis.com (Michael Jones)
Date: Mon, 2 Mar 2015 23:05:00 -0700
Subject: [Haskell-cafe] Difficulty making a TH template for a monadic
expression
Message-ID: <4C901F80-4D6A-409A-8967-71A583102C59@proclivis.com>
I?m at wits end as to how to express a monadic expression in TH. I?ll give here two ways to express a non TH version, and then a TH expression that does not quite work. It generates code that compiles, but it does not evaluate properly like the non TH version. Fundamentally, the problem is use of a recursive function using quasi quoting similar to what is in the standard Show example.
Perhaps someone will have an idea on how to fix it. I have made several attempts and failed.
Non TH Example A: Do notation
?????????????
let r = BG.runBitGet flags (do
let bits = []
v >=
(\bits -> ifM BG.getBit (return $ I0_7:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_6:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_5:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_4:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_3:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_2:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_1:bits) (return $ bits)) >>=
(\bits -> ifM BG.getBit (return $ I0_0:bits) (return $ bits)))
A TH for Example B:
????????
let bitsP = varP $ mkName "bits"
let bitsE = varE $ mkName "bits"
let makeBits [] = [| "" |]
makeBits (name:names) = [| (\bits -> ifM BG.getBit (return $ $(conE name) : $bitsE) (return $ $bitsE)) >>= $(makeBits names) |]
parse >= $(makeBits bitNames))
case r of
Left error -> fail error
Right x -> return x
|]
This generates:
parseTCA9535_INPUT_PORT_0_BITS = do {flags_0 >=
((\bits_2 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_7 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_3 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_6 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_4 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_5 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_5 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_4 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_6 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_3 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_7 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_2 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_8 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_1 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
((\bits_9 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_0 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>= "")))))))));
Problems with TH
????????
The problem is the () that interferes with the order of evaluation, and the termination at the end ( ?? ). I?m no so worried about the termination. I can put something harmless there. The parens are the main problem. Calling a quasi quoter recursively is the cause, as it nests the evaluation.
I tried things like building the bits in a list, but that does not work because the BG.getBit has to run in the BitGit monad. I know I can write a simple evaluation that just returns a list of Bools and only TH for bit names, but in the final version the size of bit fields needs to be dynamic, so I need to dynamically generate code piece by piece.
I would prefer to use quasi quoting rather than build the whole thing with data types so that it is more readable.
If anyone knows of a module on hackage that does something similar, perhaps you can point me to that so I can study it.
Thanks?Mike
From fr33domlover at riseup.net Tue Mar 3 09:19:08 2015
From: fr33domlover at riseup.net (fr33domlover)
Date: Tue, 3 Mar 2015 11:19:08 +0200
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Mon, 2 Mar 2015 16:27:53 -0600
Mike Meyer wrote:
> Until you've got an objective set of ethics - or a definition of "software
> freedom" - that everyone accepts, that's just a long-winded way of saying
> "arbitrary".
Indeed there is an objective clear definition:
http://www.gnu.org/philosophy/free-sw.html
>
> Not quite. "OtherLicense" is an accepted license tag, and I take it to mean
> I can use any license I want. If you're going to place a restriction on the
> license types beyond "use one of our tags" (and if you disallow the
> otherLicense tag, then I'd say that's an arbitrary restriction), then you
> should either define the terms in it, or choose terms that are well
> defined. "free software" is so ill defined that gnu.org has to explain what
> they mean by "free software" (https://www.gnu.org/philosophy/free-sw.html).
> They even point out that there are open source software licenses that don't
> meet their definition of free (
> https://www.gnu.org/philosophy/open-source-misses-the-point.html). Their
> definition of proprietary as "not free" makes software licensed under such
> licenses proprietary, though that's certainly not common usage.
"Open source misses the point" talks about the open source movement - it
doesn't say the BSD, MIT or Apache are not free software licenses. They are!
gnu.org provides a definition of free software, which makes it quite well
defined. There's even a list of licenses.
There is nothing arbitrary about it - in the same way the law that puts
murderers in prison isn't arbitrary. It's based on ethics: the value of human
life. Free software is similarly based on the value people's freedom to control
their computing, know what they run and be able to adapt and spread it.
> So just saying "only free software licenses" or "no proprietary software"
> would make matters worse, not better, because those terms have multiple
> meanings in common use. And that makes them not only arbitrary, but vague.
The FSF's definition is the only definition I know of. If people understand it
in a different way, this only strengthens my point: make it official and
explain the details and rules, so people do understand what free software is.
If hackage.haskell.org explains this, there will be nothing vague anymore.
From codygman.consulting at gmail.com Tue Mar 3 10:00:26 2015
From: codygman.consulting at gmail.com (Cody Goodman)
Date: Tue, 3 Mar 2015 04:00:26 -0600
Subject: [Haskell-cafe] Am I using Parsec correctly?
Message-ID:
-- trying to parse the text below using Parsec:
-- ACT I.
-- SCENE I. An open place.
-- [An open place. Thunder and lightning. Enter three Witches.]
-- FIRST WITCH.
-- When shall we three meet again
-- In thunder, lightning, or in rain?
-- Here's the code I have
import Text.Parsec
import Control.Applicative
import Data.Traversable (sequenceA)
section s = sequenceA [string s, string " ", many1 letter] `endBy` char '.'
act = section "ACT"
scene = section "SCENE"
main = do
parseTest act "ACT I.\n"
parseTest scene "SCENE I."
-- this returns:
-- ?> main
-- [["ACT"," ","I"]]
-- [["SCENE"," ","I"]]
-- Am I using Parsec correctly so far?
-- After this I want to match acts (many1 act) and scenes (many1 scene) and
I believe I see how to do that, just wanting to make sure I'm on the right
track.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From nicola.gigante at gmail.com Tue Mar 3 11:03:50 2015
From: nicola.gigante at gmail.com (Nicola Gigante)
Date: Tue, 3 Mar 2015 12:03:50 +0100
Subject: [Haskell-cafe] Lifting Writer to ListT
Message-ID: <97D743F0-2B09-483A-AC9A-E32476B8D382@gmail.com>
Hi all,
Suppose I have this monad stack:
type MyMonad = ListT (Writer W)
Where ListT is done right (from the list-t package).
What I want is a nondeterministic computation where each
alternative logs to the same writer, and indeed the type of
runWriter . toList
is MyMonad a -> ([a], w)
so I think I got it right.
What I would like to do is to write an instance of MonadWriter
for this monad, but I'm stuck with the implementation of listen.
Just using lift won't work, and indeed I see that MonadWriter
lifting instances for other monads (e.g MaybeT), are a bit convoluted.
Could someone explain me a little bit what should I do (what
listen should do in a ListT in the first place)
Thank you :)
Nicola
From mwm at mired.org Tue Mar 3 11:53:56 2015
From: mwm at mired.org (Mike Meyer)
Date: Tue, 3 Mar 2015 05:53:56 -0600
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To: <54f57ce3.e342320a.087c.2f59SMTPIN_ADDED_MISSING@mx.google.com>
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
<54f57ce3.e342320a.087c.2f59SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Tue, Mar 3, 2015 at 3:19 AM, fr33domlover
wrote:
> On Mon, 2 Mar 2015 16:27:53 -0600
> Mike Meyer wrote:
> > Until you've got an objective set of ethics - or a definition of
"software
> > freedom" - that everyone accepts, that's just a long-winded way of
saying
> > "arbitrary".
> Indeed there is an objective clear definition:
> http://www.gnu.org/philosophy/free-sw.html
Applying that definition may be objective, but not everyone agrees
that it's a correct definition of free software, which makes it a
subjective definition.
> > Not quite. "OtherLicense" is an accepted license tag, and I take it to
mean
> > I can use any license I want. If you're going to place a restriction on
the
> > license types beyond "use one of our tags" (and if you disallow the
> > otherLicense tag, then I'd say that's an arbitrary restriction), then
you
> > should either define the terms in it, or choose terms that are well
> > defined. "free software" is so ill defined that gnu.org has to explain
what
> > they mean by "free software" (
https://www.gnu.org/philosophy/free-sw.html).
> > They even point out that there are open source software licenses that
don't
> > meet their definition of free (
> > https://www.gnu.org/philosophy/open-source-misses-the-point.html).
Their
> > definition of proprietary as "not free" makes software licensed under
such
> > licenses proprietary, though that's certainly not common usage.
> "Open source misses the point" talks about the open source movement - it
> doesn't say the BSD, MIT or Apache are not free software licenses. They
are!
> gnu.org provides a definition of free software, which makes it quite well
> defined. There's even a list of licenses.
While the BSD, MIT and Apache licenses are free, the GNU license list
(https://www.gnu.org/philosophy/license-list.html#NonFreeSoftwareLicenses):
provides a long list of open source licenses that aren't free.
Some of them aren't free because they are truly noxious, some aren't
free because they are poorly written, and some aren't free because the
developers restrictions they feel are reasonable, but violate that
letter if not the spirit of that definition.
> There is nothing arbitrary about it - in the same way the law that puts
> murderers in prison isn't arbitrary. It's based on ethics: the value of
human
> life. Free software is similarly based on the value people's freedom to
control
> their computing, know what they run and be able to adapt and spread it.
Yes, but not everyone agrees to something you would think would be
clearcut, like the value of a human life. For instance, some cultures
feel that giving your own life for the good of your religion is the
best thing you can do with it, and think nothing of taking away some
non-believers life for that cause. And in other cultures, your life
isn't yours but the states, and you don't have the right to end it
yourself.
Since there's such broad disagreement on the value of a human life,
then it should be no surprise that people disagree on an idea as
recent as "free software". For instance, I find it a bit ironic that a
defintion of "free software" puts restrictions on derived works that
the original author doesn't have to abid by.
> > So just saying "only free software licenses" or "no proprietary
software"
> > would make matters worse, not better, because those terms have multiple
> > meanings in common use. And that makes them not only arbitrary, but
vague.
> The FSF's definition is the only definition I know of. If people
understand it
> in a different way, this only strengthens my point: make it official and
> explain the details and rules, so people do understand what free software
is.
> If hackage.haskell.org explains this, there will be nothing vague anymore.
Pointing to an external definition is certainly an acceptable way to
clear up the issue of the meaning of the phrase. However, I object to
any definition that excludes open source licenses that would otherwise
be useable under the otherLicnese tag for reasons I find capricious
(i.e - any license with a "no commercial use" clause is excluded, and
the lovely "must use for good" clause in the JSON license causes it to
be excluded).
The OSI's definition of open source doesn't have any of those
problems. How about using it: http://opensource.org/definition
From hesselink at gmail.com Tue Mar 3 11:59:26 2015
From: hesselink at gmail.com (Erik Hesselink)
Date: Tue, 3 Mar 2015 12:59:26 +0100
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Mon, Mar 2, 2015 at 11:27 PM, Mike Meyer wrote:
> Not quite. "OtherLicense" is an accepted license tag, and I take it to mean
> I can use any license I want.
That's not quite true, since AllRightsReserved is rejected. I think
the idea is that hackage only wants to accept licenses where people
can at least build and run that one package without any further
restrictions. It's true that this is not documented anywhere or fully
fleshed out, and it probably should be.
Erik
From vogt.adam at gmail.com Tue Mar 3 13:03:46 2015
From: vogt.adam at gmail.com (adam vogt)
Date: Tue, 3 Mar 2015 08:03:46 -0500
Subject: [Haskell-cafe] Difficulty making a TH template for a monadic
expression
In-Reply-To: <4C901F80-4D6A-409A-8967-71A583102C59@proclivis.com>
References: <4C901F80-4D6A-409A-8967-71A583102C59@proclivis.com>
Message-ID:
Hi Mike,
Is there some reason you decided to use TH, when it looks like you can write:
f :: a -> Binary (Maybe a)
f con = do
v Binary [a]
makeBits con = catMaybes mapM f con
and have the TH part be much smaller:
toCons :: [Name] -> ExpQ
toCons = listE . map conE
makeBits $(toCons bitNames)
If you really do need to generate code, let me suggest
combine :: [ExpQ] -> ExpQ
combine = foldr1 (\ a b -> [| $a >>= $b |])
together with
g :: Name -> ExpQ
g name = [| \bits -> ifM getBit ((return $(conE name) : bits) (return bits) |]
gets you
makeBits = combine . map g
Or you could keep the recursion explicit and write the first clause of
your makeBits:
makeBits [name] = g name -- g as above
Regards,
Adam
On Tue, Mar 3, 2015 at 1:05 AM, Michael Jones wrote:
> I?m at wits end as to how to express a monadic expression in TH. I?ll give here two ways to express a non TH version, and then a TH expression that does not quite work. It generates code that compiles, but it does not evaluate properly like the non TH version. Fundamentally, the problem is use of a recursive function using quasi quoting similar to what is in the standard Show example.
>
> Perhaps someone will have an idea on how to fix it. I have made several attempts and failed.
>
> Non TH Example A: Do notation
> ?????????????
>
> let r = BG.runBitGet flags (do
> let bits = []
> v bits v bits v bits v bits v bits v bits v bits v bits
> return $! bits)
>
>
> Non TH Example B: Bind notation
> ??????????????
>
> let r = BG.runBitGet flags (
> return [] >>=
> (\bits -> ifM BG.getBit (return $ I0_7:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_6:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_5:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_4:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_3:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_2:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_1:bits) (return $ bits)) >>=
> (\bits -> ifM BG.getBit (return $ I0_0:bits) (return $ bits)))
>
>
> A TH for Example B:
> ????????
>
> let bitsP = varP $ mkName "bits"
> let bitsE = varE $ mkName "bits"
> let makeBits [] = [| "" |]
> makeBits (name:names) = [| (\bits -> ifM BG.getBit (return $ $(conE name) : $bitsE) (return $ $bitsE)) >>= $(makeBits names) |]
> parse flags let r = BG.runBitGet flags (return [] >>= $(makeBits bitNames))
> case r of
> Left error -> fail error
> Right x -> return x
> |]
>
> This generates:
>
> parseTCA9535_INPUT_PORT_0_BITS = do {flags_0 let r_1 = Data.Binary.Strict.BitGet.runBitGet flags_0
> (GHC.Base.return [] GHC.Base.>>=
> ((\bits_2 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_7 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_3 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_6 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_4 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_5 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_5 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_4 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_6 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_3 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_7 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_2 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_8 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_1 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
> ((\bits_9 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_0 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>= "")))))))));
>
> Problems with TH
> ????????
>
> The problem is the () that interferes with the order of evaluation, and the termination at the end ( ?? ). I?m no so worried about the termination. I can put something harmless there. The parens are the main problem. Calling a quasi quoter recursively is the cause, as it nests the evaluation.
>
> I tried things like building the bits in a list, but that does not work because the BG.getBit has to run in the BitGit monad. I know I can write a simple evaluation that just returns a list of Bools and only TH for bit names, but in the final version the size of bit fields needs to be dynamic, so I need to dynamically generate code piece by piece.
>
> I would prefer to use quasi quoting rather than build the whole thing with data types so that it is more readable.
>
> If anyone knows of a module on hackage that does something similar, perhaps you can point me to that so I can study it.
>
> Thanks?Mike
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From fa-ml at ariis.it Tue Mar 3 15:25:54 2015
From: fa-ml at ariis.it (Francesco Ariis)
Date: Tue, 3 Mar 2015 16:25:54 +0100
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
Message-ID: <20150303152554.GA30032@x60s.casa>
On Sun, Mar 01, 2015 at 12:17:17AM -0500, Gershom B wrote:
> For the record, the current behaviour is as follows.
>
> [..]
>
> It would be good to specify that we ask that OtherLicense indeed be
> another recognized open-source license. That said, I do not feel strongly
> about how much care we take to enforce this. We should definitely better
> document this and other elements of hackage policy, and I know
> discussions about that have in fact been underway.
>
> I agree that being able to filter Hackage packages on license and other
> considerations (say, build reports on various systems) would be a great
> feature. Some such improvements have been floated as GSoC projects. I
> would encourage those that feel strongly about such features to consider
> getting involved with development of the hackage server.
Thanks for the explanation Gershom. Hackage hacking is quite a mysterious
topic for me now, but I wrote a small cabal patch to encourage devs to
pick recognized free/open-source licenses.
[1] https://mail.haskell.org/pipermail/cabal-devel/2015-March/010019.html
From marcin.jan.mrotek at gmail.com Tue Mar 3 15:58:10 2015
From: marcin.jan.mrotek at gmail.com (Marcin Mrotek)
Date: Tue, 3 Mar 2015 16:58:10 +0100
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To: <20150303152554.GA30032@x60s.casa>
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<20150303152554.GA30032@x60s.casa>
Message-ID:
Hello,
Hackage accepts source packages only anyway. Why would anyone upload
propertiary code and risk it being stolen? Noone uploads non-free
software to Hackage, it's safe to assume noone will ever do (except
perhaps as an act of trolling, and such packages could be just flat
out removed), so why fix it when it isn't broken? Also, as it was
already pointed out by Mike Meyer, a list of pre-approved licenses
doesn't solve the problem of compatibility and permission to actually
build and distribute binaries at all, and it would be better solved by
providing some tools to view and check licenses of the transitive
closure of dependencies of a package (which would, incidentally, make
it easy to weed out non-free packages too, for anyone who desires so)
Best regards,
Marcin Mrotek
From mike at proclivis.com Tue Mar 3 16:00:54 2015
From: mike at proclivis.com (Michael Jones)
Date: Tue, 3 Mar 2015 09:00:54 -0700
Subject: [Haskell-cafe] Difficulty making a TH template for a monadic
expression
In-Reply-To:
References: <4C901F80-4D6A-409A-8967-71A583102C59@proclivis.com>
Message-ID: <4CE1F919-4256-4985-89F3-9AFC70E3881D@proclivis.com>
Adam,
I used TH because I wanted a non-programmer to write simple statements from data sheets that generated code for a programmer. My ignorance may prove my undoing, but if I learn something by going down a rabbit hole, I can recover.
I don?t need to implement g necessarily, as it is part of a larger function generating other TH code, f would be fine.
The goal is to have a non-programmer write something like:
$(makeCommandData (mkName "RegTCA9535") ["INPUT_PORT_0",
"INPUT_PORT_1",
"OUTPUT_PORT_0",
"OUTPUT_PORT_1",
"POLARITY_INVERSION_PORT_0",
"POLARITY_INVERSION_PORT_1",
"CONFIGURATION_PORT_0",
"CONFIGURATION_PORT_1"])
(makeBitData (mkName "TCA9535_INPUT_PORT_0_BITS") [mkName "I0_7",
"I0_6",
"I0_5",
"I0_4",
"I0_3",
"I0_2",
"I0_1",
"I0_0?])
MORE REGISTERS HERE
and generate a complete API that works off a list of bits, and read/writes SMBus.
I have a GSOC project posted here: http://elinux.org/Minnowboard:GSoC2015
The code I am working on here is kind of starter code for that. I already have an SMBus API and impl as well on a MinnowBoardMax running Ubuntu.
If any students are interested, follow the link.
Mike
On Mar 3, 2015, at 6:03 AM, adam vogt wrote:
> Hi Mike,
>
> Is there some reason you decided to use TH, when it looks like you can write:
>
> f :: a -> Binary (Maybe a)
> f con = do
> v return (do guard v; Just con)
>
> makeBits :: [a] -> Binary [a]
> makeBits con = catMaybes mapM f con
>
> and have the TH part be much smaller:
>
> toCons :: [Name] -> ExpQ
> toCons = listE . map conE
>
> makeBits $(toCons bitNames)
>
>
>
> If you really do need to generate code, let me suggest
>
> combine :: [ExpQ] -> ExpQ
> combine = foldr1 (\ a b -> [| $a >>= $b |])
>
> together with
>
> g :: Name -> ExpQ
> g name = [| \bits -> ifM getBit ((return $(conE name) : bits) (return bits) |]
>
> gets you
>
> makeBits = combine . map g
>
>
> Or you could keep the recursion explicit and write the first clause of
> your makeBits:
>
> makeBits [name] = g name -- g as above
>
> Regards,
> Adam
>
>
> On Tue, Mar 3, 2015 at 1:05 AM, Michael Jones wrote:
>> I?m at wits end as to how to express a monadic expression in TH. I?ll give here two ways to express a non TH version, and then a TH expression that does not quite work. It generates code that compiles, but it does not evaluate properly like the non TH version. Fundamentally, the problem is use of a recursive function using quasi quoting similar to what is in the standard Show example.
>>
>> Perhaps someone will have an idea on how to fix it. I have made several attempts and failed.
>>
>> Non TH Example A: Do notation
>> ?????????????
>>
>> let r = BG.runBitGet flags (do
>> let bits = []
>> v > bits > v > bits > v > bits > v > bits > v > bits > v > bits > v > bits > v > bits >
>> return $! bits)
>>
>>
>> Non TH Example B: Bind notation
>> ??????????????
>>
>> let r = BG.runBitGet flags (
>> return [] >>=
>> (\bits -> ifM BG.getBit (return $ I0_7:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_6:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_5:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_4:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_3:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_2:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_1:bits) (return $ bits)) >>=
>> (\bits -> ifM BG.getBit (return $ I0_0:bits) (return $ bits)))
>>
>>
>> A TH for Example B:
>> ????????
>>
>> let bitsP = varP $ mkName "bits"
>> let bitsE = varE $ mkName "bits"
>> let makeBits [] = [| "" |]
>> makeBits (name:names) = [| (\bits -> ifM BG.getBit (return $ $(conE name) : $bitsE) (return $ $bitsE)) >>= $(makeBits names) |]
>> parse > flags > let r = BG.runBitGet flags (return [] >>= $(makeBits bitNames))
>> case r of
>> Left error -> fail error
>> Right x -> return x
>> |]
>>
>> This generates:
>>
>> parseTCA9535_INPUT_PORT_0_BITS = do {flags_0 > let r_1 = Data.Binary.Strict.BitGet.runBitGet flags_0
>> (GHC.Base.return [] GHC.Base.>>=
>> ((\bits_2 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_7 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_3 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_6 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_4 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_5 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_5 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_4 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_6 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_3 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_7 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_2 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_8 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_1 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>> ((\bits_9 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_0 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>= "")))))))));
>>
>> Problems with TH
>> ????????
>>
>> The problem is the () that interferes with the order of evaluation, and the termination at the end ( ?? ). I?m no so worried about the termination. I can put something harmless there. The parens are the main problem. Calling a quasi quoter recursively is the cause, as it nests the evaluation.
>>
>> I tried things like building the bits in a list, but that does not work because the BG.getBit has to run in the BitGit monad. I know I can write a simple evaluation that just returns a list of Bools and only TH for bit names, but in the final version the size of bit fields needs to be dynamic, so I need to dynamically generate code piece by piece.
>>
>> I would prefer to use quasi quoting rather than build the whole thing with data types so that it is more readable.
>>
>> If anyone knows of a module on hackage that does something similar, perhaps you can point me to that so I can study it.
>>
>> Thanks?Mike
>>
>>
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From mwm at mired.org Tue Mar 3 16:11:24 2015
From: mwm at mired.org (Mike Meyer)
Date: Tue, 3 Mar 2015 10:11:24 -0600
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<20150303152554.GA30032@x60s.casa>
Message-ID:
On Tue, Mar 3, 2015 at 9:58 AM, Marcin Mrotek
wrote:
> Also, as it was
> already pointed out by Mike Meyer, a list of pre-approved licenses
> doesn't solve the problem of compatibility and permission to actually
> build and distribute binaries at all, and it would be better solved by
> providing some tools to view and check licenses of the transitive
> closure of dependencies of a package (which would, incidentally, make
> it easy to weed out non-free packages too, for anyone who desires so)
>
BTW, part of the tools are already available: the cabal-dependency-licenses
package claims to report all your dependencies sorted by license type.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From mike at proclivis.com Tue Mar 3 16:11:40 2015
From: mike at proclivis.com (Michael Jones)
Date: Tue, 3 Mar 2015 09:11:40 -0700
Subject: [Haskell-cafe] Difficulty making a TH template for a monadic
expression
In-Reply-To: <4CE1F919-4256-4985-89F3-9AFC70E3881D@proclivis.com>
References: <4C901F80-4D6A-409A-8967-71A583102C59@proclivis.com>
<4CE1F919-4256-4985-89F3-9AFC70E3881D@proclivis.com>
Message-ID: <31C39186-C771-48D0-9EDF-B7B2AD123FC6@proclivis.com>
I failed to strip all the mkNames from the example. They are in the current code but will be moved inside the make functions later. So...
> $(makeCommandData ("RegTCA9535") ["INPUT_PORT_0",
> "INPUT_PORT_1",
> "OUTPUT_PORT_0",
> "OUTPUT_PORT_1",
> "POLARITY_INVERSION_PORT_0",
> "POLARITY_INVERSION_PORT_1",
> "CONFIGURATION_PORT_0",
> "CONFIGURATION_PORT_1"])
>
> (makeBitData ("TCA9535_INPUT_PORT_0_BITS") ["I0_7",
> "I0_6",
> "I0_5",
> "I0_4",
> "I0_3",
> "I0_2",
> "I0_1",
> "I0_0?])
On Mar 3, 2015, at 9:00 AM, Michael Jones wrote:
> Adam,
>
> I used TH because I wanted a non-programmer to write simple statements from data sheets that generated code for a programmer. My ignorance may prove my undoing, but if I learn something by going down a rabbit hole, I can recover.
>
> I don?t need to implement g necessarily, as it is part of a larger function generating other TH code, f would be fine.
>
> The goal is to have a non-programmer write something like:
>
> $(makeCommandData (mkName "RegTCA9535") ["INPUT_PORT_0",
> "INPUT_PORT_1",
> "OUTPUT_PORT_0",
> "OUTPUT_PORT_1",
> "POLARITY_INVERSION_PORT_0",
> "POLARITY_INVERSION_PORT_1",
> "CONFIGURATION_PORT_0",
> "CONFIGURATION_PORT_1"])
>
> (makeBitData (mkName "TCA9535_INPUT_PORT_0_BITS") [mkName "I0_7",
> "I0_6",
> "I0_5",
> "I0_4",
> "I0_3",
> "I0_2",
> "I0_1",
> "I0_0?])
>
> MORE REGISTERS HERE
>
>
>
> and generate a complete API that works off a list of bits, and read/writes SMBus.
>
> I have a GSOC project posted here: http://elinux.org/Minnowboard:GSoC2015
>
> The code I am working on here is kind of starter code for that. I already have an SMBus API and impl as well on a MinnowBoardMax running Ubuntu.
>
> If any students are interested, follow the link.
>
> Mike
>
> On Mar 3, 2015, at 6:03 AM, adam vogt wrote:
>
>> Hi Mike,
>>
>> Is there some reason you decided to use TH, when it looks like you can write:
>>
>> f :: a -> Binary (Maybe a)
>> f con = do
>> v > return (do guard v; Just con)
>>
>> makeBits :: [a] -> Binary [a]
>> makeBits con = catMaybes mapM f con
>>
>> and have the TH part be much smaller:
>>
>> toCons :: [Name] -> ExpQ
>> toCons = listE . map conE
>>
>> makeBits $(toCons bitNames)
>>
>>
>>
>> If you really do need to generate code, let me suggest
>>
>> combine :: [ExpQ] -> ExpQ
>> combine = foldr1 (\ a b -> [| $a >>= $b |])
>>
>> together with
>>
>> g :: Name -> ExpQ
>> g name = [| \bits -> ifM getBit ((return $(conE name) : bits) (return bits) |]
>>
>> gets you
>>
>> makeBits = combine . map g
>>
>>
>> Or you could keep the recursion explicit and write the first clause of
>> your makeBits:
>>
>> makeBits [name] = g name -- g as above
>>
>> Regards,
>> Adam
>>
>>
>> On Tue, Mar 3, 2015 at 1:05 AM, Michael Jones wrote:
>>> I?m at wits end as to how to express a monadic expression in TH. I?ll give here two ways to express a non TH version, and then a TH expression that does not quite work. It generates code that compiles, but it does not evaluate properly like the non TH version. Fundamentally, the problem is use of a recursive function using quasi quoting similar to what is in the standard Show example.
>>>
>>> Perhaps someone will have an idea on how to fix it. I have made several attempts and failed.
>>>
>>> Non TH Example A: Do notation
>>> ?????????????
>>>
>>> let r = BG.runBitGet flags (do
>>> let bits = []
>>> v >> bits >> v >> bits >> v >> bits >> v >> bits >> v >> bits >> v >> bits >> v >> bits >> v >> bits >>
>>> return $! bits)
>>>
>>>
>>> Non TH Example B: Bind notation
>>> ??????????????
>>>
>>> let r = BG.runBitGet flags (
>>> return [] >>=
>>> (\bits -> ifM BG.getBit (return $ I0_7:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_6:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_5:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_4:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_3:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_2:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_1:bits) (return $ bits)) >>=
>>> (\bits -> ifM BG.getBit (return $ I0_0:bits) (return $ bits)))
>>>
>>>
>>> A TH for Example B:
>>> ????????
>>>
>>> let bitsP = varP $ mkName "bits"
>>> let bitsE = varE $ mkName "bits"
>>> let makeBits [] = [| "" |]
>>> makeBits (name:names) = [| (\bits -> ifM BG.getBit (return $ $(conE name) : $bitsE) (return $ $bitsE)) >>= $(makeBits names) |]
>>> parse >> flags >> let r = BG.runBitGet flags (return [] >>= $(makeBits bitNames))
>>> case r of
>>> Left error -> fail error
>>> Right x -> return x
>>> |]
>>>
>>> This generates:
>>>
>>> parseTCA9535_INPUT_PORT_0_BITS = do {flags_0 >> let r_1 = Data.Binary.Strict.BitGet.runBitGet flags_0
>>> (GHC.Base.return [] GHC.Base.>>=
>>> ((\bits_2 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_7 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_3 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_6 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_4 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_5 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_5 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_4 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_6 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_3 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_7 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_2 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_8 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_1 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>=
>>> ((\bits_9 -> Control.Conditional.ifM Data.Binary.Strict.BitGet.getBit (GHC.Base.return GHC.Base.$ (I0_0 GHC.Types.: bits)) (GHC.Base.return GHC.Base.$ bits)) GHC.Base.>>= "")))))))));
>>>
>>> Problems with TH
>>> ????????
>>>
>>> The problem is the () that interferes with the order of evaluation, and the termination at the end ( ?? ). I?m no so worried about the termination. I can put something harmless there. The parens are the main problem. Calling a quasi quoter recursively is the cause, as it nests the evaluation.
>>>
>>> I tried things like building the bits in a list, but that does not work because the BG.getBit has to run in the BitGit monad. I know I can write a simple evaluation that just returns a list of Bools and only TH for bit names, but in the final version the size of bit fields needs to be dynamic, so I need to dynamically generate code piece by piece.
>>>
>>> I would prefer to use quasi quoting rather than build the whole thing with data types so that it is more readable.
>>>
>>> If anyone knows of a module on hackage that does something similar, perhaps you can point me to that so I can study it.
>>>
>>> Thanks?Mike
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
From nrujac at gmail.com Tue Mar 3 16:22:49 2015
From: nrujac at gmail.com (Arjun Comar)
Date: Tue, 3 Mar 2015 11:22:49 -0500
Subject: [Haskell-cafe] Lifting Writer to ListT
In-Reply-To: <97D743F0-2B09-483A-AC9A-E32476B8D382@gmail.com>
References: <97D743F0-2B09-483A-AC9A-E32476B8D382@gmail.com>
Message-ID:
You might prefer using the ListT
implementation from the Pipes package which has instances for MonadReader,
MonadWriter, and MonadState already. Also, the provided source might give
you some insight into how to write these instances for the list-t:ListT
type.
On Tue, Mar 3, 2015 at 6:03 AM, Nicola Gigante
wrote:
> Hi all,
>
> Suppose I have this monad stack:
>
> type MyMonad = ListT (Writer W)
>
> Where ListT is done right (from the list-t package).
> What I want is a nondeterministic computation where each
> alternative logs to the same writer, and indeed the type of
>
> runWriter . toList
>
> is MyMonad a -> ([a], w)
>
> so I think I got it right.
>
> What I would like to do is to write an instance of MonadWriter
> for this monad, but I'm stuck with the implementation of listen.
>
> Just using lift won't work, and indeed I see that MonadWriter
> lifting instances for other monads (e.g MaybeT), are a bit convoluted.
>
> Could someone explain me a little bit what should I do (what
> listen should do in a ListT in the first place)
>
> Thank you :)
> Nicola
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From cam at uptoisomorphism.net Tue Mar 3 16:31:29 2015
From: cam at uptoisomorphism.net (Casey McCann)
Date: Tue, 3 Mar 2015 11:31:29 -0500
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Tue, Mar 3, 2015 at 6:59 AM, Erik Hesselink wrote:
>
> On Mon, Mar 2, 2015 at 11:27 PM, Mike Meyer wrote:
> > Not quite. "OtherLicense" is an accepted license tag, and I take it to mean
> > I can use any license I want.
>
> That's not quite true, since AllRightsReserved is rejected. I think
> the idea is that hackage only wants to accept licenses where people
> can at least build and run that one package without any further
> restrictions. It's true that this is not documented anywhere or fully
> fleshed out, and it probably should be.
Yes, although that would require some decision or consensus on what we
expect to be able to do with code on Hackage...
My personal minimum expectation would be that anyone can always "cabal
install" anything and use it as-is without worrying about licensing.
Only when modifying code, writing code that pulls in multiple
dependencies, or uploading new code to hackage should licensing issues
really need to be considered.
For specific rules I suppose that would be something like requiring
that everything can be:
- Redistributed unmodified in source form
- Fetched and used locally with no restrictions
- Built without modification and distributed in binary form with no
restrictions beyond attribution and a link to Hackage
- Used and redistributed under the same license as any code it
contains FFI bindings to.
With all of the above taking into account the licenses of recursive
dependencies as well.
In particular, I'd personally be willing to accept code on Hackage
that restricts redistribution with modifications, but probably not any
other kind of significantly "non-free" license. I'd also be okay with
Hackage rejecting packages that can't be used/redistributed due to
conflicting licenses among its dependencies.
- C.
From silvio.frischi at gmail.com Tue Mar 3 16:46:46 2015
From: silvio.frischi at gmail.com (silvio)
Date: Tue, 03 Mar 2015 17:46:46 +0100
Subject: [Haskell-cafe] is it possible to implement Functor for
ByteString and Text
In-Reply-To:
References: <54F212C9.6040509@gmail.com>
Message-ID: <54F5E576.8030706@gmail.com>
cool trick. This is by far the best solution yet. Of course it's a bit
deceptive in what you are working with. E.g.
bs1
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>
<54f4d7f7.079d2a0a.736b.0ec0SMTPIN_ADDED_MISSING@mx.google.com>
Message-ID:
On Tue, Mar 3, 2015 at 10:31 AM, Casey McCann
wrote:
> Yes, although that would require some decision or consensus on what we
> expect to be able to do with code on Hackage...
>
> My personal minimum expectation would be that anyone can always "cabal
> install" anything and use it as-is without worrying about licensing.
> Only when modifying code, writing code that pulls in multiple
> dependencies, or uploading new code to hackage should licensing issues
> really need to be considered.
I'd rather that people not have to worry about license issues when
uploading new code, either. They're trying to give the community code
to use. If they want to attach restrictions on that use, it should be
the users problem to comply with those restrictions, not the uploaders
problem. At least beyond the permissions implicit in uploading the
software in the first place, anyway.
> For specific rules I suppose that would be something like requiring
> that everything can be:
So let's go over your list and see how a few licenses stack up.
> - Redistributed unmodified in source form
Pretty much the definition of open source.
> - Fetched and used locally with no restrictions
Softare licensed under the AGPL doesn't meet this requirement.
> - Built without modification and distributed in binary form with no
> restrictions beyond attribution and a link to Hackage
Only if "without modification" means you don't use a library built
from the software in an application you are planning on
distributing. Because if you do so, then your binary is considered a
derived work, and is no different from any other modification.
If you want the ability to build a library without modification and
then distribute a binary that uses it, then all the GPL licenses but
the LGPL fail this requirement, and most licenses on the "not
compatible with the GPL" list will fail it as well because the usual
reason for incompatibility is adding restrictions to such a
distribution.
> - Used and redistributed under the same license as any code it
> contains FFI bindings to.
Well, this depends on the license that the FFI code, not the license
of the code on hackage. Those are usually the same license, but it's
not a requirement.
This touches on a problem I have with the current license
field. People may want to dual license something, or dual licensing
may be required by code they have used in it. But there's no way to
indicate dual licensing except to pick otherLicense and then document
it a such. For instance, if you incorporate MPL and GPL code, the
resulting code should be dual licensed. It'd be nice if the license
field in a cabal file could be a list for these cases.
> In particular, I'd personally be willing to accept code on Hackage
> that restricts redistribution with modifications, but probably not any
> other kind of significantly "non-free" license. I'd also be okay with
> Hackage rejecting packages that can't be used/redistributed due to
> conflicting licenses among its dependencies.
The dependency licensing only kicks in on redistribution if you're
distributing binaries. Redistributing source doesn't include any form
of the dependencies, so their licenses don't matter. An inability to
redistribute binaries because of depencency licenses doesn't bother me
much, so long as I can still use them. If I want to redistribute such
binaries, then I have a number of options. But that should be my
problem, and not something that should impact people who don't want to
distribute binaries by, for instance, having the software not be
available on Hackage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From rajath_krishna at yahoo.co.in Tue Mar 3 17:36:29 2015
From: rajath_krishna at yahoo.co.in (S J Rajath Krishna)
Date: Tue, 3 Mar 2015 17:36:29 +0000 (UTC)
Subject: [Haskell-cafe] (no subject)
Message-ID: <1882957410.1452873.1425404189194.JavaMail.yahoo@mail.yahoo.com>
I would like to create an account with the following user name
User name :? "raxerz"? (Without the quotes)
Thanks,S J Rajath Krishna
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From ivan.miljenovic at gmail.com Tue Mar 3 17:38:21 2015
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Wed, 4 Mar 2015 04:38:21 +1100
Subject: [Haskell-cafe] (no subject)
In-Reply-To: <1882957410.1452873.1425404189194.JavaMail.yahoo@mail.yahoo.com>
References: <1882957410.1452873.1425404189194.JavaMail.yahoo@mail.yahoo.com>
Message-ID:
On 4 March 2015 at 04:36, S J Rajath Krishna wrote:
> I would like to create an account with the following user name
>
> User name : "raxerz" (Without the quotes)
On Hackage? The Haskell Wiki?
>
>
> Thanks,
> S J Rajath Krishna
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com
From fa-ml at ariis.it Tue Mar 3 17:48:18 2015
From: fa-ml at ariis.it (Francesco Ariis)
Date: Tue, 3 Mar 2015 18:48:18 +0100
Subject: [Haskell-cafe] Hackage and Free Software
In-Reply-To:
References: <20150228172446.3CB4EBC986@haskell.org>
<20150228205938.GA12510@x60s.casa>