Re: [Haskell-cafe] An APL library for Haskell
Interesting idea. It seems like building this on top of REPA would save a lot of work, since it has a native notion of rank encoded in the type system. I'd then see the APL-like combinators as a niche API for REPA, rather than as a library of their own. And of course, you'd get parallelization for free, more or less. I think some of the combinators on that wiki page already have counterparts in the REPA API. On Thu, Mar 8, 2012 at 8:44 AM, Simon Peyton-Jones simo...@microsoft.comwrote: Friends ** ** Many of you will know the array language APLhttp://en.wikipedia.org/wiki/APL_%28programming_language%29. It focuses on arrays and in particular has a rich, carefully-thought-out array algebra. ** ** An obvious idea is: *what would a Haskell library that embodies APL’s array algebra look like*? In conversation with John Scholes and some of his colleagues in the APL community a group of us developed some ideas for a possible API, which you can find on the Haskell wiki here: http://www.haskell.org/haskellwiki/APL ** ** However, we have all gone our separate ways, and I think it’s entirely possible that that the idea will go no further. So this message is to ask: **· **Is anyone interested in an APL-style array library in Haskell? **· **If so, would you like to lead the process of developing the API? ** ** I think there are quite a few people who would be willing to contribute, including some core gurus from the APL community: John Scholes, Arthur Whitney, and Roger Hui. ** ** Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Rank N Kinds
The higher universe levels are mostly used to stave off logical paradoxes in languages where you care about that kind of stuff. In a fundamentally impredicative language like Haskell I don't see much point, but I'd be happy to find there is one :) On Thu, Aug 1, 2013 at 4:55 PM, Wvv vite...@rambler.ru wrote: I'm sorry, `instance Functor (TupleList (a :: **)) where ...` isn't right, sure. The right one is `instance Functor TupleList where ...` -- View this message in context: http://haskell.1045720.n5.nabble.com/Rank-N-Kinds-tp5733482p5733700.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] closed world instances, closed type families
It seems very similar to Ryan Ingram's post a few years back (pre-TypeNats): http://www.haskell.org/pipermail/haskell-cafe/2009-June/062690.html The main difference is that he introduces the knowledge about zero vs. suc as a constraint, and you introduce it as a parameter. In fact, his induction function (which is probably what I'd call it too) is almost identical to your switch. Anyway, it's cool stuff :) I don't have a name for it, but I enjoy it. On Tue, Apr 2, 2013 at 4:28 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: Recently I needed to define a class with a restricted set of instances. After some failed attempts I looked into the DataKinds extension and in Giving Haskell a Promotion I found the example of a new kind Nat for type level peano numbers. However the interesting part of a complete case analysis on type level peano numbers was only sketched in section 8.4 Closed type families. Thus I tried again and finally found a solution that works with existing GHC extensions: data Zero data Succ n class Nat n where switch :: f Zero - (forall m. Nat m = f (Succ m)) - f n instance Nat Zero where switch x _ = x instance Nat n = Nat (Succ n) where switch _ x = x That's all. I do not need more methods in Nat, since I can express everything by the type case analysis provided by switch. I can implement any method on Nat types using a newtype around the method which instantiates the f. E.g. newtype Append m a n = Append {runAppend :: Vec n a - Vec m a - Vec (Add n m) a} type family Add n m :: * type instance Add Zero m = m type instance Add (Succ n) m = Succ (Add n m) append :: Nat n = Vec n a - Vec m a - Vec (Add n m) a append = runAppend $ switch (Append $ \_empty x - x) (Append $ \x y - case decons x of (a,as) - cons a (append as y)) decons :: Vec (Succ n) a - (a, Vec n a) cons :: a - Vec n a - Vec (Succ n) a The technique reminds me on GADTless programming. Has it already a name? __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FunPtr to C function with #arguments determined atruntime?
Considering that the GHC FFI is already built on libffi (I'm reasonably sure) it seems unnecessary for the Hackage library to depend on an external version. Is it not already getting linked in? On Sun, Feb 17, 2013 at 6:53 PM, Ryan Newton rrnew...@gmail.com wrote: The scenario is pretty simple. I generate C code at runtime. I compile it to a .so. I know how many arguments it expects (but only at runtime), and I get a FunPtr back from 'dlsym'. How do I call it? I feel that I might be confused about the problem, but since I don't see anyone direct answers -- in order to call a FunPtr, you can use foreign import ccall dynamic, to create a regular function. As described in the library documentation for Foreign.Ptr, which I bet you've seen, so you know this. You can cast the FunPtr to whatever type you like, so you can call the function with an argument list different from its initial declaration. My problem is that I can't create a type representing what I want at the Haskell type-check time, and I need such a type for either casting or a foreign import. For example, let's say the function takes a number of Int arguments between 1 and 1000. If I find out at runtime that I need a function with 613 Int arguments, I would need to create the type (Int - Int ... - IO ()) to cast to. I suppose there may be some way to create such a dependent type with Typeable/Data.Dynamic, since it's monomorphic. Or in theory you could dynamically generate new Haskell code to create the type (System.Eval.Haskell)... libffi, which Krzysztof mentioned, is a good solution: http://www.haskell.org/haskellwiki/Library/libffi Because it allows you to pass a list of arguments callFFI :: FunPtr a - RetType b - [Arg] - IO b But it does introduce an extra dependency on a C library (read, deployment liability). It cabal install'd the first time on my linux box, but my mac said The pkg-config package libffi is required but it could not be found. (even though libffi.dylib is definitely installed globally). Anyway, in this case it wasn't *too *painful to just generate a bunch of extra boilerplate C functions for (1) creating a data structure to hold the arguments, (2) loading them in one at a time, and (3) deallocating the structure when the call is done. Yuck. But no extra dependencies. Cheers, -Ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?
Although I agree that Functor should be a superclass of Monad, the two methods of the Monad typeclass _are_ sufficient to make any instance into a Functor in a mechanical/automatic way. The language may not know it, but return/bind is equivalent in power to fmap/return/join. Apart from bind being easier to use for the things we typically do with monads in programs, using bind is actually more succinct in that it doesn't require three primitive operations. I'm not saying bind is a better primitive than join/fmap, but mathematicians do it this way, therefore it's better doesn't seem like a particularly convincing argument either. And for a more philosophical question, is something not a functor just because we don't have a Functor instance for it? If we agree that the Monad class (with no Functor superclass) does implicitly form a Functor with liftM, then I don't really see what the problem is, apart from the inconvenience of not being able to use fmap. On Tue, Oct 16, 2012 at 10:37 AM, AUGER Cédric sedri...@gmail.com wrote: Le Tue, 16 Oct 2012 09:51:29 -0400, Jake McArthur jake.mcart...@gmail.com a écrit : On Mon, Oct 15, 2012 at 11:29 PM, Dan Doel dan.d...@gmail.com wrote: I'd be down with putting join in the class, but that tends to not be terribly important for most cases, either. Join is not the most important, but I do think it's often easier to define than bind. I often find myself implementing bind by explicitly using join. join IS the most important from the categorical point of view. In a way it is natural to define 'bind' from 'join', but in Haskell, it is not always possible (see the Monad/Functor problem). As I said, from the mathematical point of view, join (often noted μ in category theory) is the (natural) transformation which with return (η that I may have erroneously written ε in some previous mail) defines a monad (and requires some additionnal law). As often some points it out, Haskellers are not very right in their definition of Monad, not because of the bind vs join (in fact in a Monad either of them can be defined from the other one), but because of the functor status of a Monad. A monad, should always be a functor (at least to fit its mathematical definition). And this problem with the functor has probably lead to the use of bind (which is polymorphic in two type variables) rather than join (which has only one type variable, and thus is simpler). The problem, is that when 'm' is a Haskell Monad which does not belong to the Functor class, we cannot define 'bind' in general from 'join'. That is in the context where you have: return:∀ a. a → (m a) join:∀ a. (m (m a)) → (m a) x:m a f:a → (m b) you cannot define some term of type 'm b', since you would need to use at the end, either 'f' (and you would require to produce a 'a' which would be impossible), or 'return' (and you would need to produce a 'b', which is impossible), or 'join' (and you would need to produce a 'm (m b)', and recursively for that you cannot use return which would make you go back to define a 'm b' term) For that, you need the 'fmap' operation of the functor. return:∀ a. a → (m a) join:∀ a. (m (m a)) → (m a) fmap:∀ a b. (a→b) → ((m a)→(m b)) x:m a f:a → (m b) in this context defining a term of type 'm b' is feasible (join (fmap f x)), so that you can express bind = \ x f - join (fmap f x). To sum up, mathematical monads are defined from 'return' and 'join' as a mathematical monad is always a functor (so 'fmap' is defined, and 'bind', which is more complex than 'join' can be defined from 'join' and 'fmap'). Haskell does not use a very good definition for their monads, as they may not be instance of the Functor class (although most of them can easily be defined as such), and without this 'fmap', 'join' and 'return' would be pretty useless, as you wouldn't be able to move from a type 'm a' to a type 'm b'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question about type inference of a GADT term
Shouldn't you have IxZero :: Ix (CtxCons ty ctx) ty instead of IxZero :: Ix ctx ty On Fri, Sep 21, 2012 at 8:34 AM, Florian Lorenzen florian.loren...@tu-berlin.de wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello cafe, I have the following GADT definitions capturing the simply typed lambda calculus with de Bruijn indices for variables and explicitly annotated types for variables: {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DataKinds #-} - -- Typing contexts data Ctx = CtxNil | CtxCons Ctx Type - -- Types data Type = TyInt | TyArrow Type Type - -- Variable indices data Ix (ctx :: Ctx) (ty :: Type) where IxZero :: Ix ctx ty IxSucc :: Ix ctx ty1 - Ix (CtxCons ctx ty2) ty1 - -- Type representations data TyRep (ty :: Type) where TyRepInt :: TyRep TyInt TyRepArrow :: TyRep ty1 - TyRep ty2 - TyRep (TyArrow ty1 ty2) - -- Terms data Term (ctx :: Ctx) (ty :: Type) where TmInt :: Integer - Term ctx TyInt TmVar :: Ix ctx ty - Term ctx ty TmAdd :: Term ctx TyInt - Term ctx TyInt - Term ctx TyInt TmApp :: Term ctx (TyArrow ty1 ty2) - Term ctx ty1 - Term ctx ty2 TmAbs :: TyRep ty1 - Term (CtxCons ctx ty1) ty2 - Term ctx (TyArrow ty1 ty2) For the following definition test1 = TmAbs TyRepInt (TmVar IxZero) GHCi infers the type test1 :: Term ctx (TyArrow 'TyInt ty2) I was a bit puzzled because I expected Term ctx (TyArrow TyInt TyInt) Of course, this more special type is an instance of the inferred one, so I can assign it by a type signature. Can someone explain why the inferred type is more general? Terms like test2 = TmAbs TyRepInt (TmAdd (TmVar IxZero) (TmInt 5)) have the type I expected: test2 :: Term ctx (TyArrow 'TyInt 'TyInt) Thank you and best regards, Florian - -- Florian Lorenzen Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin Tel.: +49 (30) 314-24618 E-Mail: florian.loren...@tu-berlin.de WWW:http://www.user.tu-berlin.de/florenz/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBcXs4ACgkQvjzICpVvX7b1WQCePiL+SFNj9X+U0V2fnykuatLX pIcAn1VDNRiSR18s7UgctdPeNzFgStbi =LBGb -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?
That doesn't require existential quantification, but it'll need Rank-2 types if you ever do anything with Job. Unfortunately, a universally quantified Job like what you wrote (or what Magicloud seems to want) is only inhabited by the empty Map. An existentially quantified Job, as you might get with data Job = forall k a. Job (Map k a) does let you wrap up any Map containing anything in it, but unfortunately the only thing you can do with that map afterwards is ask for structural properties about it, like whether it's empty or how many elements it has in it. You could ask to enumerate the elements in it, but you wouldn't be able to touch any of them because you wouldn't know what their types were. So I'm not really sure how to interpret the question. Was the goal to have a heterogeneous Map, maybe? Or just to avoid having to type type variables all over the place? Both of those are possible but require a bit more sophistication with types. -Dan On Wed, Jun 13, 2012 at 7:32 AM, Ismael Figueroa Palet ifiguer...@gmail.com wrote: Do you want to hide the specific types of the job? Presumably to then define a type JobList = [Job] ? You can do that with the ExistentialQuantification extension. type Job = forall k a. Map k a type JobList = [Job] ?? Note you can't unpack the types k a once you have hidden them. But the typechecker can use it to ensure some static property. Also you could use unsafeCoerce to do some casts, but *only if you are *sure* that things will go OK*. 2012/6/13 Magicloud Magiclouds magicloud.magiclo...@gmail.com Hi, I've forgotten this. This is OK: type Job k a = Map k a And this is OK: {-# LANGUAGE RankNTypes #-} -- or LiberalTypeSynonyms? type Job = forall a. forall k. Map k a Then how to write it like this? type Job = Map k a -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ismael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] webcam library on github
On Fri, May 25, 2012 at 3:07 AM, . ch.go...@googlemail.com wrote: The gpl is sort of my default license. I know it is a little restrictive, so if that keeps people (if any) from contributing, I will change the license. As far as I can see, I would be able to change it to lgpl then, but not to bsd. I'm no lawyer, but my understanding is that the code is yours and you are free to license it however you want. If you choose to license your code as BSD and depend on LGPL code, then *your users* are bound by both the BSD And LGPL licenses, which is effectively as bad as being bound by the LGPL. Your portion of the code is still BSD-licensed, though. The distinction would probably be more evident if someone then made a BSD replacement for your dependencies, in which case they would no longer be bound by the LGPL terms if they used your library. The Haskell community does seem to have a cultural attachment to more permissive licenses, so you'll likely see a lot more adoption if you do use BSD, but it's obviously up to you. -Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unit and pair
FullBinaryTreeRelation? :P On Tue, May 8, 2012 at 1:36 PM, MigMit miguelim...@yandex.ru wrote: Hi café, a quick question. Is there a somewhat standard class like this: class Something c where unit :: c () () pair :: c x y - c u v - c (x, u) (y, v) ? I'm using it heavily in my current project, but I don't want to repeat somebody else's work, and it seems general enough to be defined somewhere; but my quick search on Hackage didn't reveal anything. I know about arrows; this, however, is something more general, and it's instances aren't always arrows. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unit and pair
To expand on that, this class basically allows you to prove your relation cholds pointwise across arbitrary binary trees, represented by nested tuples and terminated by ()s. If individual instances of the class had additional ways of constructing values (i.e., proving the relation for the two type parameters), then your trees could contain other types. For example, if you had another type data Iso a b = Iso (a - b) (b - a) -- the functions must be inverses you could write an instance of Something for Iso and build a proof that ((), (a, ((), b)) is isomorphic to ((), (c, ((), d)) given Iso a c and Iso b dusing your class. I'm not sure I'd bundle the two parts together, but I'd call your pairmethod (or the class it lives in) something like congruent or ProductsRespectThisRelation :) Dan On Tue, May 8, 2012 at 3:15 PM, Daniel Peebles pumpkin...@gmail.com wrote: FullBinaryTreeRelation? :P On Tue, May 8, 2012 at 1:36 PM, MigMit miguelim...@yandex.ru wrote: Hi café, a quick question. Is there a somewhat standard class like this: class Something c where unit :: c () () pair :: c x y - c u v - c (x, u) (y, v) ? I'm using it heavily in my current project, but I don't want to repeat somebody else's work, and it seems general enough to be defined somewhere; but my quick search on Hackage didn't reveal anything. I know about arrows; this, however, is something more general, and it's instances aren't always arrows. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I am having trouble with the type declaration for creating an identity matrix.
Your problem is that you're including the (i, j) in your array element type, when you really only want it to be in your index type (I assume). This would not normally be an issue, but an unboxed array doesn't work on an element type of ((Int, Int), Double). You might consider instead making a new unboxed array with a default value of 0.0, and then forM_ an action that writes 1.0 at index (i, i). On Tue, Apr 24, 2012 at 5:20 PM, KC kc1...@gmail.com wrote: initIdentityMat :: Int - ST s (STUArray s (Int,Int) ((Int, Int), Double)) initIdentityMat m = newListArray ((1,m),(1,m)) ([((i,j), if i == j then 1.0 else 0.0) | i - [1..m], j - [1..m]] :: [((Int,Int), Double)]) Doesn't seem to compile, nor do minor variations of the type declaration. -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] is this an arrow?
On Fri, Apr 13, 2012 at 7:49 AM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: type Computer a b = ( a - IO ( Maybe b ) ) type Transformer a b c d = Computer a ( b, c - d ) Computer looks like Kleisli (MaybeT IO), which would be a valid instance of Arrow. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Category Theory Questions
I doubt anyone will mind too much, but you probably want to stick to the category theory that is obviously applicable to Haskell (and ideally talk/ask about how it applies). Questions about initial algebras and Lambek's lemma will probably get decent responses, whereas globe categories and anafunctors, for example, might not. If it's just straight-up category theory for its own sake, you might have better luck on math-specific forums (stack exchange, for example), though. Dan On Mon, Apr 9, 2012 at 12:37 AM, Sergiu Ivanov unlimitedscol...@gmail.comwrote: Hello, I have a question not that directly related to Haskell, but I still think this is a good place to ask it. I am currently studying category theory by the book Joy of Cats. Are there any people whom I could ask some questions related to category theory from time to time? Or could I just post my questions here directly? The reason I'm asking is that I seen very nice discussions related to category theory on this list. I hope to be able to deal with most of the stuff myself, but having someone to discuss the matters with is always nice :-) Sergiu [0] katmat.math.uni-bremen.de/acc/acc.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generalizing (++) for monoids instead of using ()
There are many reasons, but some of the more cited ones are that () will break less code than (++) would, since (++) is ubiquitous and () is most used in some pretty printers. Yes, mappend's type can be refined to that of the current list (++), but the increased polymorphism still has the potential to break existing code by making it harder to resolve instances. As for () meaning not equal to, do you also have a problem with Monad's () meaning a right bitwise shift, or the mutationey form of it, (=)? :) I don't think anyone in Haskell has ever used () to mean (/=), so the fact that there exist a couple of languages out there that do use it that way shouldn't affect our decision. Dan On Sun, Apr 1, 2012 at 4:58 PM, aditya bhargava bluemangrou...@gmail.comwrote: After asking this question: http://stackoverflow.com/questions/9963050/standard-way-of-joining-two-data-texts-without-mappend I found out that the new infix operator for `mappend` is (). I'm wondering why ghc 7.4 didn't generalize (++) to work on monoids instead. To me, (++) is much more clear. () means not equal to for me. Can anyone shed light on this decision? Adit -- adit.io ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mathematics and Statistics libraries
I'd like to see more statistics work, definitely. Bryan's statistics library is excellent, but Ed Kmett has been talking about some very interesting approaches to sampling from complicated distributions, which I'd like to see implemented eventually in a library. On Wed, Mar 21, 2012 at 1:24 PM, Ben Jones ben.jamin.pw...@gmail.comwrote: I am a student currently interested in participating in Google Summer of Code. I have a strong interest in Haskell, and a semester's worth of coding experience in the language. I am a mathematics and cs double major with only a semester left and I am looking for information regarding what the community is lacking as far as mathematics and statistics libraries are concerned. If there is enough interest I would like to put together a project with this. I understand that such libraries are probably low priority, but if anyone has anything I would love to hear it. Thanks for reading, -Benjamin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell compilers targeting VMs
A more subtle issue is that there's some sort of memory leak that arises when you can't instruct the GC to follow projection functions of data types. I believe the GHC heap representation has a built-in notion of these forwarding closures and the GC follows them when possible, but most VM GCs are just black boxes. It might still be possible to create an artificial field in a representation of your closure that the GC can follow, but it could be tricky. On Thu, Feb 23, 2012 at 11:59 AM, Tom Murphy amin...@gmail.com wrote: There are some substantial technical challenges: http://www.haskell.org/haskellwiki/GHC:FAQ#Why_isn.27t_GHC_available_for_.NET_or_on_the_JVM.3F Not that it can't be done, but there's nothing ready yet. Tom (IRC: amindfv) On 2/23/12, ARJANEN Loïc Jean David arjanen.l...@gmail.com wrote: Hello, Does any one knows of an Haskell compiler targeting the JVM ? And of one targeting the .Net virtual machine ? Regards, ARJANEN Loïc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] On the purity of Haskell
This thread pretty much exemplifies why many people don't bother with this mailing list anymore. On Sun, Jan 1, 2012 at 7:00 PM, AUGER Cédric sedri...@gmail.com wrote: Le Sun, 1 Jan 2012 16:31:51 -0500, Dan Doel dan.d...@gmail.com a écrit : On Sun, Jan 1, 2012 at 3:26 PM, Ketil Malde ke...@malde.org wrote: Chris Smith cdsm...@gmail.com writes: I wonder: can writing to memory be called a “computational effect”? If yes, then every computation is impure. I wonder if not the important bit is that pure computations are unaffected by other computations (and not whether they can affect other computations). Many pure computations have side effects (increases temperature, modifies hardware registers and memory, etc), but their effect can only be observed in IO. (E.g. Debug.Trace.trace provides a non-IO interface by use of unsafePerformIO which is often considered cheating, but in this view it really is pure.) The point of purity (and related concepts) is to have useful tools for working with and reasoning about your code. Lambda calculi can be seen as the prototypical functional languages, and the standard ones have the following nice property: The only difference between reduction strategies is termination. Non-strict strategies will terminate for more expressions than strict ones, but that is the only difference. This has nothing to do with purity (purity and strictness/lazyness are different). This property is often taken to be the nub of what it means to be a pure functional language. If the language is an extension of the lambda calculus that preserves this property, then it is a pure functional language. Haskell with the 'unsafe' stuff removed is such a language by this definition, and most GHC additions are too, depending on how you want to argue. It is even true with respect to the output of programs, but not when you're using Debug.Trace, because: flip (+) (foo `trace` 1) (bar `trace` 1) will print different things with different evaluation orders. A similar property is referential transparency, which allows you to factor your program however you want without changing its denotation. So: (\x - x + x) e is the same as: e + e That is not really what I call referential transparency; for me this is rather β reduction… For me, referential transparency means that the same two closed expression in one context denote the same value. So that is rather: let x = e y = e in x + y is the same as: e + e This actually fails for strict evaluation strategies unless you relax it to be 'same denotation up to bottoms' or some such. But not having to worry about whether you're changing the definedness of your programs by factoring/inlining is actually a useful property that strict languages lack. In fact, strict language can be referentially transparent; it is the case in ML (in fact I only know of Ocaml minus impure features, but well…). Also, the embedded IO language does not have this property. do x - m ; f x x is different from do x - m ; y - m ; f x y In fact IO IS referentially transparent; do NOT FORGET that there is some syntactic sugar: do x - m ; f x x = (=) m (\x - f x x) do x - m ; y - m ; f x y = (=) m (\x - (=) m (\y - f x y)) So when we desugar it (and it is only desugaring, it is no optimization/reduction/whatEverElseYouWant; these two expressions have the same AST once parsed), where would you want to put referential transparency? and so on. This is why you shouldn't write your whole program with IO functions; it lacks nice properties for working with your code. But the embedded IO language lacking this property should not be confused with Haskell lacking this property. It is not an embedded IO language, it is just some sugar for monads; you can as well do: maybePlus :: (Mabe Int) - (Maybe Int) - Maybe Int maybePlus mx my = do x - mx y - my return $ x+y and there is absolutely no IO. Anyhow, here's my point: these properties can be grounded in useful features of the language. However, for the vast majority of people, being able to factor their code differently and have it appear exactly the same to someone with a memory sniffer isn't useful. And unless you're doing serious crypto or something, there is no correct amount of heat for a program to produce. So if we're wondering about whether we should define purity or referential transparency to incorporate these things, the answer is an easy, no. We throw out the possibility that 'e + e' may do more work than '(\x - x + x) e' for the same reason (indeed, we often want to factor it so that it performs better, while still being confident that it is in some sense the same program, despite the fact that performing better might by some definitions mean that it isn't the
Re: [Haskell-cafe] smt solver bindings
Not that I know of, but I would like them too. There are a few bindings to yices, but I don't think yices has the feature I want in it. On Thu, Dec 15, 2011 at 1:04 PM, Dimitrios Vytiniotis dimit...@microsoft.com wrote: I've a quick question: Are there Haskell wrappers for the Z3 C API around? Thanks! d- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A Mascot
I like it! On Wed, Nov 16, 2011 at 1:01 AM, heathmatlock heathmatl...@gmail.comwrote: I liked Go's mascot, and I figure it couldn't hurt to have our own. I spent the past hour making this: http://i.imgur.com/Mib6Q.png What do you think? -- Heath Matlock +1 256 274 4225 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Vector.Unboxed
Yes, it does. You can only use members of the Elt class in repa arrays, and Elt has Unbox as a superclass. On Thu, Nov 10, 2011 at 5:03 PM, Yves Parès limestr...@gmail.com wrote: Does Repa always use unboxed Vectors? But a Repa array can store any element, so how does it handles types which haven't an unboxed equivalent? Or is the unboxing done automatically? 2011/11/10 Bas van Dijk v.dijk@gmail.com On 9 November 2011 22:33, kaffeepause73 kaffeepaus...@yahoo.de wrote: Repa is indeed very Interesting, but I have changing vector length in the second dimension and later on only want to generate Data on demand. If I use Matrices, I will use loads of space for no reason. Even if it is possible to create an unboxed vector of unboxed vectors, if the inner unboxed vectors have variable lengths as you require, indexing will become O(n) instead of O(1) because you need to traverse the inner unboxed vectors and check their length to find the desired index. I'm not sure that's what you want. Seems like sticking to Boxed Vector for now is best Choice for me. Yes your second alternative: a boxed vector of unboxed vectors seems to do what you want. isn't data.vector also providing multidimensional arrays? I don't think so. All indexing functions get a single Int argument. Of course it's easy to build a layer on top that adds more dimensions. So is Repa just another Version of Data.Vector or is it building another level on top. The latter, repa provides a layer on top of vector. Note that you can also convert Vectors to repa Arrays using: fromVector :: Shape sh = sh - Vector a - Array sh a I believe its O(1). And when to use best which of the two ? I guess when your vectors are multi-dimensional and you want to benefit from parallelism you should use repa instead of vector. Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] arr considered harmful
Have you seen Adam Megacz's work on generalized arrows? I think he proposes to kill arr and has done a decent amount of work on it. On Mon, Oct 31, 2011 at 8:33 PM, Ryan Ingram ryani.s...@gmail.com wrote: I know it's a bit of an 'intentionally provocative' title, but with the recent discussions on Arrows I thought it timely to bring this up. Most of the conversion from arrow syntax into arrows uses 'arr' to move components around. However, arr is totally opaque to the arrow itself, and prevents describing some very useful objects as arrows. For example, I would love to be able to use the arrow syntax to define objects of this type: data Circuit a b where Const :: Bool - Circuit () Bool Wire :: Circuit a a Delay :: Circuit a a And :: Circuit (Bool,Bool) Bool Or :: Circuit (Bool,Bool) Bool Not :: Circuit Bool Bool Then :: Circuit a b - Circuit b c - Circuit a c Pair :: Circuit a c - Circuit b d - Circuit (a,b) (c,d) First :: Circuit a b - Circuit (a,c) (b,c) Swap :: Circuit (a,b) (b,a) AssocL :: Circuit ((a,b),c) (a,(b,c)) AssocR :: Circuit (a,(b,c)) ((a,b),c) Loop :: Circuit (a,b) (a,c) - Circuit b c etc. Then we can have code that examines this concrete data representation, converts it to VHDL, optimizes it, etc. However, due to the presence of the opaque 'arr', there's no way to make this type an arrow without adding an 'escape hatch' Arr :: (a - b) - Circuit a b which breaks the abstraction: circuit is supposed to represent an actual boolean circuit; (Arr not) is not a valid circuit because we've lost the information about the existence of a 'Not' gate. The arrow syntax translation uses arr to do plumbing of variables. I think a promising project would be to figure out exactly what plumbing is needed, and add those functions to a sort of 'PrimitiveArrow' class. All of these plumbing functions are trivially implemented in terms of 'arr', when it exists, but if it doesn't, it should be possible to use the arrow syntax regardless. -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Smarter do notation
Good idea! I'd forgotten about monad comprehensions. On Sun, Sep 4, 2011 at 3:11 AM, Shachaf Ben-Kiki shac...@gmail.com wrote: On Sat, Sep 3, 2011 at 19:34, Daniel Peebles pumpkin...@gmail.com wrote: ... Of course, the fact that the return method is explicitly mentioned in my example suggests that unless we do some real voodoo, Applicative would have to be a superclass of Monad for this to make sense. But with the new default superclass instances people are talking about in GHC, that doesn't seem too unlikely in the near future. ... One way to avoid explicitly mentioning return would be to use monad comprehension syntax, which uses return implicitly, instead of do notation. This also has the advantage of being new in GHC 7.2, rather than officially being part of Haskell 98/2010, and therefore being more amenable to various extensions (e.g. there are already extensions that use MonadPlus/MonadZip/MonadGroup). Applicative would probably still have to be a superclass of Monad, but the translation of this syntax is simpler. Shachaf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Smarter do notation
Yeah, I use SHE and her idiom brackets for several of my projects, but there are many cases in which they're awkward too. Another consideration about the monad comprehensions is that unbound (i.e., with no -) statements in a monad comprehension are treated as MonadPlus guards, so the applicative * and * wouldn't really have a clean place to go. On Sun, Sep 4, 2011 at 1:32 PM, Dominique Devriese dominique.devri...@cs.kuleuven.be wrote: It's not the same as what you propose, but it's related, so for discussion, I just want to point out idiom brackets (an analog for do-notation for Applicative functors) which have been introduced in some Haskell-related languages. Examples are Idris (http://www.cs.st-andrews.ac.uk/~eb/Idris/donotation.html) and SHE (http://personal.cis.strath.ac.uk/~conor/pub/she/idiom.html). Dominique 2011/9/4 Daniel Peebles pumpkin...@gmail.com: Hi all, I was wondering what people thought of a smarter do notation. Currently, there's an almost trivial desugaring of do notation into (=), (), and fail (grr!) which seem to naturally imply Monads (although oddly enough, return is never used in the desugaring). The simplicity of the desugaring is nice, but in many cases people write monadic code that could easily have been Applicative. For example, if I write in a do block: x - action1 y - action2 z - action3 return (f x y z) that doesn't require any of the context-sensitivty that Monads give you, and could be processed a lot more efficiently by a clever Applicative instance (a parser, for instance). Furthermore, if return values are ignored, we could use the ($), (*), or (*) operators which could make the whole thing even more efficient in some instances. Of course, the fact that the return method is explicitly mentioned in my example suggests that unless we do some real voodoo, Applicative would have to be a superclass of Monad for this to make sense. But with the new default superclass instances people are talking about in GHC, that doesn't seem too unlikely in the near future. On the implementation side, it seems fairly straightforward to determine whether Applicative is enough for a given do block. Does anyone have any opinions on whether this would be a worthwhile change? The downsides seem to be a more complex desugaring pass (although still something most people could perform in their heads), and some instability with making small changes to the code in a do block. If you make a small change to use a variable before the return, you instantly jump from Applicative to Monad and might break types in your program. I'm not convinced that's necessary a bad thing, though. Any thoughts? Thanks, Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Smarter do notation
Hi all, I was wondering what people thought of a smarter do notation. Currently, there's an almost trivial desugaring of do notation into (=), (), and fail (grr!) which seem to naturally imply Monads (although oddly enough, return is never used in the desugaring). The simplicity of the desugaring is nice, but in many cases people write monadic code that could easily have been Applicative. For example, if I write in a do block: x - action1 y - action2 z - action3 return (f x y z) that doesn't require any of the context-sensitivty that Monads give you, and could be processed a lot more efficiently by a clever Applicative instance (a parser, for instance). Furthermore, if return values are ignored, we could use the ($), (*), or (*) operators which could make the whole thing even more efficient in some instances. Of course, the fact that the return method is explicitly mentioned in my example suggests that unless we do some real voodoo, Applicative would have to be a superclass of Monad for this to make sense. But with the new default superclass instances people are talking about in GHC, that doesn't seem too unlikely in the near future. On the implementation side, it seems fairly straightforward to determine whether Applicative is enough for a given do block. Does anyone have any opinions on whether this would be a worthwhile change? The downsides seem to be a more complex desugaring pass (although still something most people could perform in their heads), and some instability with making small changes to the code in a do block. If you make a small change to use a variable before the return, you instantly jump from Applicative to Monad and might break types in your program. I'm not convinced that's necessary a bad thing, though. Any thoughts? Thanks, Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Smarter do notation
With parsers, for example, it amounts to you have a context-free vs. a context-sensitive language. The functions hidden behind a monadic bind are effectively opaque to any sort of analysis, whereas the static structure of an applicative can be analyzed as much as you want. Ed Kmett does this in his trifecta parsing library (I think there's a couple of other libraries that also do this), but you have to use the applicative interface explicitly where possible to take advantage of the additional optimizations. This would also have benefits for other sorts of EDSLs, for the same reason. An applicative computation might for example be sparked and processed in parallel, whereas it's a lot harder (impossible) to do that if your structure isn't determined beforehand. On Sun, Sep 4, 2011 at 12:24 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 4 September 2011 12:34, Daniel Peebles pumpkin...@gmail.com wrote: Hi all, For example, if I write in a do block: x - action1 y - action2 z - action3 return (f x y z) that doesn't require any of the context-sensitivty that Monads give you, and could be processed a lot more efficiently by a clever Applicative instance (a parser, for instance). What advantage is there in using Applicative rather than Monad for this? Does it _really_ lead to an efficiency increase? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] bitSize
And as Daniel mentioned earlier, it's not at all obvious what we mean by bits used when it comes to negative numbers. GMP pretends that any negative number has infinite bits in the two's-complement representation. Should we count the highest _unset_ bit when the number is negative? Or to put it another way, what invariants should the proposed bit-counting function satisfy? On Thu, Aug 25, 2011 at 6:32 PM, Albert Y. C. Lai tre...@vex.net wrote: On 11-08-25 01:57 PM, Andrew Coppin wrote: Does anybody else think it would be *far* more useful if bitSize applied to an Integer would tell you how many bits that particular Integer is using? Especially given that it can vary? It is useful to know the number of bits used in a value. It is useful to know the maximum number of bits storable in a type. It is useless to conflate the two into one single method. The name bitSize is already taken. Come up with another name, and I will agree with you. __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there a program to check if a matrix is totally unimodular?
I haven't come across unimodular matrices before, but according to the definition on wikipedia it seems fairly straightforward to implement a naive algorithm to decide it. Also, have you considered trying IRC for these sorts of short questions? The #haskell IRC channel on freenode is helpful and seems better suited to asking questions like this, if you just want quick answers. There's a shorter lag than a mailing list, and the IRC medium seems closer to the kinds of things I've seen you ask. From observing the mailing list for quite a while, it seems that if you want a decent conversation on here, you should ask more fleshed-out questions with an explanation of some background to the problem, and more details on what you want and why. -Dan On Wed, Aug 3, 2011 at 5:45 PM, KC kc1...@gmail.com wrote: -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Category theory as a design tool
Hey, I think you forgo On Wed, Jun 22, 2011 at 12:20 AM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Hello, I ha ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Map: Values to keys and keys to values
Why not make it unlossy and have: trans :: (Ord k, Ord a) = Map k a - Map a (Set k) On Thu, Jun 16, 2011 at 9:10 AM, Johan Tibell johan.tib...@gmail.comwrote: On Thu, Jun 16, 2011 at 3:01 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: Hi, Data.Map has many great functions, yet I could not find the one that allows from one map create another map where keys are values and values are keys of the first one. Something like: transMap:: (Ord k, Ord a) = Map k a - Map a k Does such function exist? Note that such a function would be lossy as there might be duplicate values in the map. Cheers, Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to install GhC on a Mac without registering?
Isn't gcc just used for its assembler and object file creation, these days, now that via-C is deprecated? Or are there other parts of it that are needed? On Mon, Jun 6, 2011 at 10:47 AM, Malcolm Wallace malcolm.wall...@me.comwrote: On 6 Jun 2011, at 13:49, Lyndon Maydwell wrote: I would be fantastic if XCode wasn't a dependency. ... Not to detract at all from the work of the wonderful GHC and Haskell Platform contributors in any way. For me it would just make it that much easier to convince mac-using friends to give Haskell a try. The ghc team already bundle a copy of gcc in their Windows distribution, precisely because it can be fiddly to get a working copy of gcc for that platform otherwise. I wonder if they would consider the possibility of shipping gcc on Mac too? (There may be good reasons not to do that, but let's have the discussion.) Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to install GhC on a Mac without registering?
I thought Apple had stopped bundling the dev tools with installation DVDs? On Fri, Jun 3, 2011 at 4:32 PM, Judah Jacobson judah.jacob...@gmail.comwrote: Hi John, You should be able to install the Apple Developer Tools directly from one of the software installation DVDs that come with the Mac. If you're not downloading the tools from online, you shouldn't need to register. Best, -Judah On Fri, Jun 3, 2011 at 1:03 PM, John D. Ramsdell ramsde...@gmail.com wrote: I rarely use a Mac because it is too cute, but I bought one for my wife. I'd like to install GHC on her Mac just to test Haskell Platform and cabal install. (I rarely use Windows too, but testing GHC cabal install is completely painless.) To do a quick test, do I really have to register as an Apple developer, or is there a way to test the platform anonymously? Someone who some times worries about privacy, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Extension for Pearls of Functional Algorithm Design by Richard Bird, 2010, page 25 #Haskell
Do you have some sort of link aggregator that auto-posts to haskell-cafe? On Sat, May 21, 2011 at 12:09 AM, KC kc1...@gmail.com wrote: Extension for Pearls of Functional Algorithm Design by Richard Bird, 2010, page 25 #Haskell --- --- module SelectionProblem where import Data.Array import Data.List --- --- -- Question: is there a way to get the type signature as the following: -- smallest :: (Ord a) = Int - [Array Int a] - a --- --- -- Works on 2 finite ordered disjoint sets represented as sorted arrays. smallest :: (Ord a) = Int - (Array Int a, Array Int a) - a smallest k (xa,ya) = search k (xa,ya) (0,m+1) (0,n+1) where (0,m) = bounds xa (0,n) = bounds ya -- Removed some of the indexitis at the cost of calling another function. search :: (Ord a) = Int - (Array Int a, Array Int a) - (Int,Int) - (Int,Int) - a search k (xa,ya) (lx,rx) (ly,ry) | lx == rx = ya ! (k+ly) | ly == ry = xa ! (k+lx) | otherwise = case (xa ! mx ya ! my) of (True)- smallest2h k (xa,ya) ((lx,mx,rx),(ly,my,ry)) (False) - smallest2h k (ya,xa) ((ly,my,ry),(lx,mx,rx)) where mx = (lx+rx) `div` 2 my = (ly+ry) `div` 2 -- Here the sorted arrays are in order by their middle elements. -- Only cutting the leading or trailing array by half. -- Here xa is the first array and ya the second array by their middle elements. smallest2h :: (Ord a) = Int - (Array Int a, Array Int a) - ((Int,Int,Int),(Int,Int,Int)) - a smallest2h k (xa,ya) ((lx,mx,rx),(ly,my,ry)) = case (k=mx-lx+my-ly) of (True)- search k (xa,ya) (lx,rx) (ly,my) (False) - search (k-(mx-lx)-1) (xa,ya) (mx+1,rx) (ly,ry) --- --- -- Works on 3 finite ordered disjoint sets represented as sorted arrays. smallest3 :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) - a smallest3 k (xa,ya,za) = -- On each recursive call the order of the arrays can switch. search3 k (xa,ya,za) (0,bx+1) (0,by+1) (0,bz+1) where (0,bx) = bounds xa (0,by) = bounds ya (0,bz) = bounds za -- Removed some of the indexitis at the cost of calling another function. search3 :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) - (Int,Int) - (Int,Int) - (Int,Int) - a search3 k (xa,ya,za) (lx,rx) (ly,ry) (lz,rz) | lx == rx ly == ry = za ! (k+lz) | ly == ry lz == rz = xa ! (k+lx) | lx == rx lz == rz = ya ! (k+ly) | lx == rx = search k (ya,za) (ly,ry) (lz,rz) | ly == ry = search k (xa,za) (lx,rx) (lz,rz) | lz == rz = search k (xa,ya) (lx,rx) (ly,ry) | otherwise = case (xa ! mx ya ! my, xa ! mx za ! mz, ya ! my za ! mz) of (True, True, True)- smallest3h k (xa,ya,za) ((lx,mx,rx),(ly,my,ry),(lz,mz,rz)) -- abc (True, True, False) - smallest3h k (xa,za,ya) ((lx,mx,rx),(lz,mz,rz),(ly,my,ry)) -- acb (False, True, True) - smallest3h k (ya,xa,za) ((ly,my,ry),(lx,mx,rx),(lz,mz,rz)) -- bac (False, False, True) - smallest3h k (ya,za,xa) ((ly,my,ry),(lz,mz,rz),(lx,mx,rx)) -- bca (True, False, False) - smallest3h k (za,xa,ya) ((lz,mz,rz),(lx,mx,rx),(ly,my,ry)) -- cab (False, False, False) - smallest3h k (za,ya,xa) ((lz,mz,rz),(ly,my,ry),(lx,mx,rx)) -- cba where mx = (lx+rx) `div` 2 my = (ly+ry) `div` 2 mz = (lz+rz) `div` 2 -- Here the sorted arrays are in order by their middle elements. -- Only cutting the leading or trailing array by half. -- Here xa is the first array, ya the second array, and za the third array by their middle elements. smallest3h :: (Ord a) = Int - (Array Int a, Array Int a, Array Int a) - ((Int,Int,Int),(Int,Int,Int),(Int,Int,Int)) - a smallest3h k (xa,ya,za) ((lx,mx,rx),(ly,my,ry),(lz,mz,rz)) = case (k=mx-lx+my-ly+mz-lz) of (True)- search3 k (xa,ya,za) (lx,rx) (ly,ry) (lz,mz) (False) - search3 (k-(mx-lx)-1) (xa,ya,za) (mx+1,rx) (ly,ry) (lz,rz) -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org
Re: [Haskell-cafe] The Lisp Curse
The way I understand it, you're saying not that we shouldn't be doing it this way (since it isn't centrally managed, it's the only possible way), but that we shouldn't be bragging (for lack of a better word) that we have lots of libraries that do a specific thing. Or if not that, then at least that it isn't a clear win. I agree that from an end-user's perspective it isn't always a clear win, but I do think that having a bunch of libraries (even ones that do the same thing) an indicator of a healthy, active, and enthusiastic community. Sure, it's decentralized and people will often duplicate effort, but different variations on the same idea can also help explore the design space and will reveal to everyone interested what works and what doesn't. But yeah, if you want to do X and you encounter 15 libraries that do X and can't find a clear consensus on what's best, I can understand why that might be frustrating. I don't think there's really a clear solution to that though, other than gently encouraging collaboration and scoping out of existing work before starting new work. But people generally hate working with other people's code, so I doubt that'll have much of an effect :) Dan On Thu, May 19, 2011 at 4:56 PM, Andrew Coppin andrewcop...@btinternet.comwrote: On 19/05/2011 09:34 PM, vagif.ve...@gmail.com wrote: Andrew, you are being non constructive. It seems I'm being misunderstood. Some people seem to hold the opinion that more libraries = better. I'm trying to voice the opinion that there is such a thing as too many libraries. The article I linked to explains part of why this is the case, in a better way than I've been able to phrase it myself. I'm not trying to say OMG, the way it is now completely sucks! I'm not trying to say you must do X right now! I'm just trying to put forward an opinion. The opinion that having too many libraries can be a problem, which some people don't seem to agree with. (Obviously it isn't *always* bad, I'm just saying that sometimes it can be.) That's all I was trying to say. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Uncatchable error
Check out the spoon package on hackage. It's designed for these kinds of situations, and will wrap up common user-generated pure exceptions into a Maybe (and will return Nothing in the cases you describe) -Dan On Fri, Mar 11, 2011 at 11:04 AM, Daniel Díaz danield...@asofilak.eswrote: Hi, cafe, I'm working in a program where I use many connections with Network.HTTP. Sometimes, connections are closed while my program is reading them, and an error appears: socket: XXX: Data.ByteString.hGetLine: invalid argument (Bad file descriptor) All I need is to handle this error. The function 'catch' doesn't work. I guess this error comes from a call to 'error' function, or something similar. What I can do? Thanks in advance, Daniel Díaz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Uncatchable error
It's a hack by design, to work around libraries that do the wrong thing. On Fri, Mar 11, 2011 at 4:07 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: On Fri, 11 Mar 2011, Daniel Peebles wrote: Check out the spoon package on hackage. It's designed for these kinds of situations, and will wrap up common user-generated pure exceptions into a Maybe (and will return Nothing in the cases you describe) This is a hack, since 'undefined' cannot be detected in general. The clean solution would be to find out where invalid file descriptors are detected in the IO code, and throw a real IOException instead of an 'error'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: hmpfr-0.3.2 (requires integer-simple, supports mpfr 3.0.0)
Have you submitted a bug report to GHC of why it can't work with the current integer-gmp binding? I know that GHC's collector is collecting MPFR's temporary data, but maybe it'd be good to get a discussion going on what can be done to stop it from doing this even in the context of the existing integer-gmp + GHC's allocator (even if this needs to be a patch to MPFR to talk to GHC a bit here and there). Might it help to go through CMM like the GMP binding does, for example? I'd really like to see libraries that use GMP work nicely with GHC, without going and reimplementing GMP more slowly and so on. Dan 2011/3/3 Michal Konečný m...@konecny.aow.cz Dear all, I am pleased to announce hmpfr-0.3.2, a new version of Aleš Bizjak's bindings to the MPFR arbitrary precision floating point arithmetic library. The changes in this version are quite small but significant: - support for MPFR 3.0.0 as well as MPFR 2.4.* - dependency on integer-simple instead of integer-gmp The latter is most significant because unfortunately it makes it rather more difficult to install hmpfr. Currently almost all binary distributions of ghc have integer-gmp compiled in to provide the Integer type via the standard GMP library. Also haskell platform 2010.2.0.0 assumes that ghc has been compiled with integer-gmp although it makes no specific use of it. Instructions on how to compile ghc and haskell platform with integer-simple instead of integer-gmp are on: http://code.google.com/p/hmpfr/wiki/GHCWithoutGMP The rationale for this change is the fact that despite much effort hmpfr is very unreliable on ghc that includes integer-gmp due to ghc deallocating GMP data that was allocated by MPFR at unpredictable times. Aleš and I hope that hmpfr can return to using integer-gmp once the proposal http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes#BinaryDropinReplacementforGMP to replace gmp with a modified gmp in ghc is implemented and made the default. Best regards, Michal -- |o| Michal Konecny mikkone...@gmail.com |o|http://www-users.aston.ac.uk/~konecnym/ |o|office: (+42) (0)121 204 3462 |o| PGP key http://www-users.aston.ac.uk/~konecnym/ki.aston ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: hmpfr-0.3.2 (requires integer-simple, supports mpfr 3.0.0)
According to Duncan Coutts (whom I asked about this issue in #ghc), the solution here is to use the new foreign import prim machinery to talk to MPFR. This prevents GC from occurring during the MPFR calls and will make everything work nicely without reimplementing GMP. Dan On Fri, Mar 4, 2011 at 3:09 PM, Daniel Peebles pumpkin...@gmail.com wrote: Have you submitted a bug report to GHC of why it can't work with the current integer-gmp binding? I know that GHC's collector is collecting MPFR's temporary data, but maybe it'd be good to get a discussion going on what can be done to stop it from doing this even in the context of the existing integer-gmp + GHC's allocator (even if this needs to be a patch to MPFR to talk to GHC a bit here and there). Might it help to go through CMM like the GMP binding does, for example? I'd really like to see libraries that use GMP work nicely with GHC, without going and reimplementing GMP more slowly and so on. Dan 2011/3/3 Michal Konečný m...@konecny.aow.cz Dear all, I am pleased to announce hmpfr-0.3.2, a new version of Aleš Bizjak's bindings to the MPFR arbitrary precision floating point arithmetic library. The changes in this version are quite small but significant: - support for MPFR 3.0.0 as well as MPFR 2.4.* - dependency on integer-simple instead of integer-gmp The latter is most significant because unfortunately it makes it rather more difficult to install hmpfr. Currently almost all binary distributions of ghc have integer-gmp compiled in to provide the Integer type via the standard GMP library. Also haskell platform 2010.2.0.0 assumes that ghc has been compiled with integer-gmp although it makes no specific use of it. Instructions on how to compile ghc and haskell platform with integer-simple instead of integer-gmp are on: http://code.google.com/p/hmpfr/wiki/GHCWithoutGMP The rationale for this change is the fact that despite much effort hmpfr is very unreliable on ghc that includes integer-gmp due to ghc deallocating GMP data that was allocated by MPFR at unpredictable times. Aleš and I hope that hmpfr can return to using integer-gmp once the proposal http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes#BinaryDropinReplacementforGMP to replace gmp with a modified gmp in ghc is implemented and made the default. Best regards, Michal -- |o| Michal Konecny mikkone...@gmail.com |o|http://www-users.aston.ac.uk/~konecnym/ |o|office: (+42) (0)121 204 3462 |o| PGP key http://www-users.aston.ac.uk/~konecnym/ki.aston ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: theoremquest-0.0.0
Have you tried it? It's completely addictive (and takes up a big chunk of my free time). I'm not sure it'll appeal to everyone, but I wouldn't dismiss it off-hand like that. On Mon, Feb 28, 2011 at 10:16 AM, Colin Adams colinpaulad...@googlemail.com wrote: On 28 February 2011 14:59, Tom Hawkins tomahawk...@gmail.com wrote: I have been wanting to gain a better understanding of interactive theorem proving for some time. And I've often wondered: Can theorem proving be made into a user-friendly game that could attract mass appeal? No. I'd wage money on it. -- Colin Adams Preston, Lancashire, ENGLAND () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
This is indeed very strange. On my latest GHC 7 (built a couple of days ago) it does the right thing when compiled, but in GHCi it behaves as you describe. I have no idea, frankly. On Thu, Feb 3, 2011 at 8:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo -- Steffen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] AES on 32-bit system
Knowing nothing about the package or its code, it looks like a typo to me. The stdint.h naming of types would have it be uint64_t, not uint_64t. Could that be it? On Fri, Feb 4, 2011 at 6:00 AM, Michael Snoyman mich...@snoyman.com wrote: Hi everyone, Does anyone else have trouble installing the AES package on a 32-bit system? My system at home installs it just fine, but my VPS chokes with the following error messages (plus a bunch of warnings): cbits/ctr_inc.c:11:0: error: 'uint_64t' undeclared (first use in this function) cbits/ctr_inc.c:11:0: error: (Each undeclared identifier is reported only once cbits/ctr_inc.c:11:0: error: for each function it appears in.) cbits/ctr_inc.c:11:0: error: 'ctr' undeclared (first use in this function) cbits/ctr_inc.c:11:0: error: expected expression before ')' token It's actually for this very reason that I'm still maintaining the OpenSSL backend for http-enumerator: I think the tls package is stable enough now to be used in production environments (kudos to Vincent by the way). However, I can't use it in production if I can't build one of its dependencies. This bug is also preventing me from adding some nice features to http-enumerator, such as checking validity of SSL certificates. Anyone have any thoughts? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Merry monad mixup?
Beware of ListT. It only works if your internal monad is commutative, which IO is not. (Maybe would work, for example) On Fri, Jan 28, 2011 at 2:41 PM, Chris Smith cdsm...@gmail.com wrote: On Fri, 2011-01-28 at 11:20 -0800, michael rice wrote: The first and third work, but not the second. Why? When you use a do block, it can be the syntactic sugar for whatever monad you like; but you do have to make a choice. Your first example had a do block for the IO monad. Your third example used the [] monad. Both are fine. The second, though, wasn't clear on what monad it was using. When you used the (-) syntax to nondeterministically choose from a list, the compiler settled upon the [] monad. But then the next line was a statement in the IO monad. That's inconsistent, hence the error. Perhaps you wanted to build a monad out of both behaviors? In this case, you should likely look into monad transformers, and in particular, the ListT monad transformer in the List package. This would allow you to write the code you did in a monad called ListT IO, except that the IO actions would need to be lifted through the use of either `lift` or `liftIO`. -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Merry monad mixup?
And by works, I mean, ListT is is a monad only if the internal monad is commutative. On Fri, Jan 28, 2011 at 2:46 PM, Daniel Peebles pumpkin...@gmail.comwrote: Beware of ListT. It only works if your internal monad is commutative, which IO is not. (Maybe would work, for example) On Fri, Jan 28, 2011 at 2:41 PM, Chris Smith cdsm...@gmail.com wrote: On Fri, 2011-01-28 at 11:20 -0800, michael rice wrote: The first and third work, but not the second. Why? When you use a do block, it can be the syntactic sugar for whatever monad you like; but you do have to make a choice. Your first example had a do block for the IO monad. Your third example used the [] monad. Both are fine. The second, though, wasn't clear on what monad it was using. When you used the (-) syntax to nondeterministically choose from a list, the compiler settled upon the [] monad. But then the next line was a statement in the IO monad. That's inconsistent, hence the error. Perhaps you wanted to build a monad out of both behaviors? In this case, you should likely look into monad transformers, and in particular, the ListT monad transformer in the List package. This would allow you to write the code you did in a monad called ListT IO, except that the IO actions would need to be lifted through the use of either `lift` or `liftIO`. -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] global, modifiable variable for debugging
Seems like you'd want x - getArgs and x == [debug] rather than the irrefutable pattern match. On Sun, Dec 26, 2010 at 3:04 PM, Michael Snoyman mich...@snoyman.comwrote: I think something like this would work: myFlag = unsafePerformIO $ do [x] - getArgs return $ x == debug In general, unsafePerformIO should be avoided, but this is one of those situations where we can give you a pass ;). Michael On Sun, Dec 26, 2010 at 9:53 PM, bri...@aracnet.com wrote: Hi, I have a program with a debug flag in it (Strangely I've yet to be able to write bug-free code). I'd like to change the state of the debug flag based on command line args. I looked at IOVar but that would cause all the pure procedures to get swallowed by the IO Monad. Is a better way to get this behavior ? Thanks, Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (Co/Contra)Functor and Comonad
I remember seeing this very discussion about pointed being disjoint from functor just recently on one of the various haskell mailing lists. But as for my opinion on it, because there's no real way of specifying any laws for pointed without functor. With functor and pointed, you can say that you expect fmap f . point == point . f, but point on its own gives you nothing to latch onto for behavior expectations. On Fri, Dec 24, 2010 at 11:08 AM, Mario Blažević mblaze...@stilo.comwrote: On Fri, Dec 24, 2010 at 7:43 AM, Maciej Piechotka uzytkown...@gmail.comwrote: On Fri, 2010-12-24 at 05:36 -0500, Edward Kmett wrote: +1 for adding Comonads. As an aside, since Haskell doesn't have (nor could it have) coexponential objects, there is no 'missing' Coapplicative concept that goes with it, so there can be no objection on the grounds of lack of symmetry even if the Functor = Applicative = Monad proposal goes through. There is still potentially useful Copointed/CoPointed: class [Functor a =] CoPointed a where copoint :: f a - a Why should Copointed, or Pointed for that matter, be a subclass of Functor? I don't see the point of arranging all possible classes into a single complete hierarchy. These single-method classes can stand on their own. Once you have them, it's easy to declare class (Functor f, Pointed f) = Applicative f and also class (Foldable f, Pointed f) = Sequence f or whatever. On Fri, Dec 24, 2010 at 4:51 AM, Stephen Tetley stephen.tet...@gmail.comwrote: On 24 December 2010 02:16, Mario Blažević mblaze...@stilo.com wrote: To turn the proof obligation around, what could possibly be the downside of adding a puny Cofunctor class to the base library? Hi Mario For the record I'm personally neutral on Cofunctor and on balance would like to see Comonad added to Base. My reservation is really at the meta-level - I suspect there are a lot of candidates for adding to Base if you want to Base to be systematic about modeling structures. There is a limited number of methods with up to N unconstrained arguments, combinatorics takes care of that. class Foo (x :: *) where method1 :: x-- default, mempty, minBound, maxBound method2 :: x - x -- succ, pred, negate method3 :: x - x - x -- mappend method4 :: (x - x) - x-- fix class Cons (c :: * - *) where method1 :: x - c x -- return, pure method2 :: c x - x -- extract method3 :: c (c x) - c x-- join method4 :: c x - c (c x)-- duplicate method5 :: c (c x) - x method6 :: x - c (c x) method7 :: x - c x - c x method8 :: c x - c x - x method9 :: (x - x) - c x - c x method10 :: (x - y) - c x - c y -- fmap method11 :: (x - y) - c y - c x -- contramap method12 :: x - c y - c y method13 :: x - c y - c x method14 :: c x - c y - x method15 :: c x - (x - c x) - c x method16 :: c x - (x - c y) - c y -- = method17 :: c x - (c x - x) - c x method18 :: c x - (c x - y) - c y -- extend I may have left something out, but all types above should be inhabited. I have omitted methods on constructors that can be defined on a plain type, such as mplus :: m a - m a - m a, which is a restriction of the type of mappend. If one were to explore the design space systematically with no backward compatibility baggage, the best approach might be: - declare each method in a class of its own, with no laws whatsoever, - never declare two methods in a same class, - combine the primitive classes into bigger classes, - restrict the bigger classes with laws. The Pointed and Copointed classes above are two examples. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proof in Haskell
I think it's pretty legit. You aren't actually making a claim about the values in the tree but I think parametricity handles that for you, especially since you have existential types for the payload at every tree level (so you can't go shuffling those around). The only thing missing (and that you can't change in Haskell) is that your statement is about Mirror (Mirror x) == x, rather than mirror (mirror x) == x. mirror gives you Mirror but there's currently no proof to show that it's the only way to do it, so there's a missing step there, I think. Anyway, for those talking about the coinductive proof, I made one in Agda: http://hpaste.org/42516/mirrormirror Simulating bottoms wouldn't be too hard, but I don't think the statement is even true in the presence of bottoms, is it? Dan On Thu, Dec 23, 2010 at 9:27 AM, Sjoerd Visscher sjo...@w3future.comwrote: On Dec 21, 2010, at 6:57 PM, austin seipp wrote: https://gist.github.com/750279 I took Austins code and modified it to run on a Tree GADT which is parameterized by its shape: https://gist.github.com/752982 Would this count as a function mirror with proof that mirror (mirror x) == x? -- Sjoerd Visscher ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proof in Haskell
Fair enough :) that'll teach me to hypothesize something without thinking about it! I guess I could amend my coinductive proof: http://hpaste.org/paste/42516/mirrormirror_with_bottom#p42517 does that cover bottom-ness adequately? I can't say I've thought through it terribly carefully. On Thu, Dec 23, 2010 at 12:30 PM, Ryan Ingram ryani.s...@gmail.com wrote: On Thu, Dec 23, 2010 at 8:19 AM, Daniel Peebles pumpkin...@gmail.com wrote: Simulating bottoms wouldn't be too hard, but I don't think the statement is even true in the presence of bottoms, is it? Isn't it? data Tree a = Tip | Node (Tree a) a (Tree a) mirror :: Tree a - Tree a mirror Tip = Tip mirror (Node x y z) = Node (mirror z) y (mirror x) -- -- base cases mirror (mirror _|_) = mirror _|_ = _|_ mirror (mirror Tip) = mirror Tip = Tip -- inductive case mirror (mirror (Node x y z)) = mirror (Node (mirror z) y (mirror x)) = Node (mirror (mirror x)) y (mirror (mirror z)) -- induction = Node x y z -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (Co/Contra)Functor and Comonad
For me, mostly naming. Cofunctor isn't the right name for it, and comap, while short, feels wrong. Contrafunctor feels better but is also cumbersome. No problems with Comonad, though. On Thu, Dec 23, 2010 at 9:16 PM, Mario Blažević mblaze...@stilo.com wrote: On Thu, Dec 23, 2010 at 5:25 PM, Stephen Tetley stephen.tet...@gmail.comwrote: On 23 December 2010 21:43, Mario Blažević mblaze...@stilo.com wrote: Why are Cofunctor and Comonad classes not a part of the base library? [SNIP] Later on I found that this question has been raised before by Conal Elliott, nearly four years ago. http://www.haskell.org/pipermail/libraries/2007-January/006740.html From a somewhat philistine persepective, that Conal's question went unanswered says something: Does anyone have useful functionality to go into a Cofunctor module (beyond the class declaration)? Successful post-H98 additions to Base (Applicative, Arrows, ...) brought a compelling programming style with them. For Comonads, Category-extras does define some extra combinators but otherwise they have perhaps seemed uncompelling. There are plenty of potential Cofunctor instances on Hackage, as I've pointed out. The other side of the proof of the utility of the class would be to find existing libraries that could be parameterized by an arbitrary functor: in other words, some examples in Hackage of class Cofunctor c = ... instance Cofunctor c = ... f :: Cofunctor c = ... This would be rather difficult to prove - such signatures cannot be declared today, and deciding if existing declarations could be generalized in this way would require a pretty deep analysis. The only thing I can say is build it and they will come. To turn the proof obligation around, what could possibly be the downside of adding a puny Cofunctor class to the base library? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why is Haskell flagging this?
Write out more types and it'll get more clear. f is [Int] - IO [Int] lst is f applied to Num a = [a], so it is of type IO [Int] fmap is applied to lst, which means it's stepping inside the IO. That means it's applying +1 to [1,2,3,4,5], which doesn't make much sense unless you have a Num instance for [Int]. That's what the error was saying. What you probably want is fmap (fmap (+1)) lst. Not sure why you're doing this stuff in the first place though, since the return into IO is only restricting what you can do with it. Also, the do in both cases is unnecessary (in the second case you can replace the let with a let..in) Hope this helps, Dan On Fri, Dec 17, 2010 at 12:04 PM, michael rice nowg...@yahoo.com wrote: I don't understand this error message. Haskell appears not to understand that 1 is a Num. Prelude :t 1 1 :: (Num t) = t Prelude :t [1,2,3,4,5] [1,2,3,4,5] :: (Num t) = [t] Prelude Michael === f :: [Int] - IO [Int] f lst = do return lst main = do let lst = f [1,2,3,4,5] fmap (+1) lst === Prelude :l test [1 of 1] Compiling Main ( test.hs, interpreted ) test.hs:5:17: No instance for (Num [Int]) arising from the literal `1' at test.hs:5:17 Possible fix: add an instance declaration for (Num [Int]) In the second argument of `(+)', namely `1' In the first argument of `fmap', namely `(+ 1)' In the expression: fmap (+ 1) lst Failed, modules loaded: none. Prelude ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] handling multiple versions of a data structure
I haven't tested this idea, but it occurred to me that this might be a good place for data families: data Z = Z newtype S n = S n -- Some nastiness to avoid having to see into the future? type family Pred n :: * type instance Pred (S n) = n type instance Pred Z = Z class MyDataClass ver where data MyData ver :: * upgrade :: MyData (Pred ver) - MyData ver -- other methods that won't change from version to version class Less a b instance Less Z a instance Less a b = Less a (S b) convert :: Less a b = MyData a - MyData b -- you may need a method in Less to witness the less-ness, but then you'd iterate your upgrade until you reach the version you want. -- Then you might want to abstract over this class with an existential, so it doesn't infect other things: data MyDataGeneral = forall ver. MyDataClass ver = MyDataGeneral ver -- now make instances for versions you have, with data instances for your current version of the structure. This might not even compile as I just wrote it into my email client, but it seems like it could work. Any comments? Dan On Thu, Dec 16, 2010 at 1:26 PM, Dmitry V'yal akam...@gmail.com wrote: Greetings, while developing my neural net simulator I stumbled upon a problem. I have a data type NeuralNet and use Show and Read instances for saving and loading configurations. As time passed, I changed the data type, so the program can no longer load files saved in previous versions. I want fix it. My current idea looks as follows. I'm going to create a bunch of types NN1, NN2, NN3..NNn for different versions and write converters c12 :: N1 - N2, c23 :: N2 - N3 and so on. But how to organize the whole process of parsing String into NNn so it's easy to change formats? Something based on using a list of parsers [read, c43 . read, c43 . c23 . read, c43, c23 . c12 . read, c43 . c32 . c21 . read] looks rather verbose and grows quadratically with N. I'm sure there must be a more elegant way. Any ideas? Dmitry ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] handling multiple versions of a data structure
Have you considered moving these packages that are unrelated to web development into a separate namespace? I know that I never considered looking under the happstack namespace simply because I never do webapps. On Thu, Dec 16, 2010 at 5:09 PM, Jeremy Shaw jer...@n-heptane.com wrote: Hello, You should use happstack-data for this (you do not need the other happstack components to use happstack-data)*. It was created to solve this exact problem. happstack-data builds on type of the 'binary' library and adds versioned data types and automatic version migration. You can get an idea as to how it works by reading this old blog post, http://nhlab.blogspot.com/2008/12/data-migration-with-happs-data.html The modules names have changed from HAppS.* to Happstack.*, but otherwise it is still pretty accurate. The upcoming happstack 7 release cycle will be focusing on this area of happstack. Especially improved documentation. But, it is quite usable right now. If you have questions about happstack-data, feel free to ask on the happstack mailing list or irc channel. (http://happstack.com/community) I am happy to answer any questions or concerns you may have. - jeremy * the version on hackage depends on happstack-util, but the darcs version does not. On Dec 16, 2010, at 12:26 PM, Dmitry V'yal wrote: Greetings, while developing my neural net simulator I stumbled upon a problem. I have a data type NeuralNet and use Show and Read instances for saving and loading configurations. As time passed, I changed the data type, so the program can no longer load files saved in previous versions. I want fix it. My current idea looks as follows. I'm going to create a bunch of types NN1, NN2, NN3..NNn for different versions and write converters c12 :: N1 - N2, c23 :: N2 - N3 and so on. But how to organize the whole process of parsing String into NNn so it's easy to change formats? Something based on using a list of parsers [read, c43 . read, c43 . c23 . read, c43, c23 . c12 . read, c43 . c32 . c21 . read] looks rather verbose and grows quadratically with N. I'm sure there must be a more elegant way. Any ideas? Dmitry ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] the beginning of the end
Oh yeah, the 2.0 stuff that snobby techies love to hate :) hrrmpf back in my day we programmed in binary using a magnetized needle on the exposed tape! I don't need any of this newfangled bull. I kid! But I am curious to see why people are so opposed to this stuff? The attitude I can't see any reason for it to exist (without having seriously tried it) seems similar to that our (haskell's) detractors use when taking a cursory glance at it and saying the syntax doesn't make sense. On Sun, Dec 5, 2010 at 12:00 PM, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/4/10 21:35 , Jason Dagit wrote: In that case, here you go: http://twitter.com/statuses/user_timeline/216043045.rss http://twitter.com/statuses/user_timeline/17788765.rss You can get those by finding them on twitter and then clicking the RSS link. Twitter might be the one idea worse than reddit for this kind of thing - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz7xR8ACgkQIn7hlCsL25UpxQCeL/v4mUjYpESgQWpDbj2ZQuyx 96sAoLiPOfvdT5r2vIRg3GxTKXntf/0c =0cvu -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About Fun with type functions example
The obvious way to write the result would be (stealing some syntax made up by ski on #haskell): fromInt :: Int - (exists n. (Nat n) * n) fromInt = ... meaning, at compile time we don't know the type of the result of fromInt, because it depends on a runtime value, but we'll tell you it's _some_ type (an existential) with a Nat instance. Now, GHC haskell doesn't support existentials like that (you can make a custom data type that wraps them) but you can invert your thinking a bit and ask yourself _who_ can consume such an existential. The only kinds of functions that can deal with an arbitrary type like that (with a Nat instance) are those that are polymorphic in it. So instead of Int - (exists n. (Nat n) * n), we flip the existential and make a continuation and say Int - (forall n. (Nat n) = n - r) - r, meaning we take the Int, and a consumer of an arbitrary type-level natural, and return what the consumer returns on our computed type-level natural. We're forced to return exactly the value that the continuation returns because we know nothing at all about the `r` type variable. Hope this helps! Dan On Fri, Nov 19, 2010 at 9:09 AM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Thanks a lot for the explanation. Summarizing: You can't calculate an exact type, but you don't care if the type of the continuation is properly set in order to hide the exact type of n? Am I right? Arnaud On Fri, Nov 19, 2010 at 9:24 AM, Miguel Mitrofanov miguelim...@yandex.ru wrote: A continuation. You can't know, what type your fromInt n should be, but you're not going to just leave it anyway, you're gonna do some calculations with it, resulting in something of type r. So, your calculation is gonna be of type (forall n. Nat n = n - r). So, if you imagine for a moment that fromInt is somehow implemented, what you're gonna do with it is something like calculate :: Int - r calculate i = let n = fromInt i in k n where k is of type (forall n. Nat n = n - r). Now we capture this pattern in a function: genericCalculate :: Int - (forall n. Nat n = n - r) - r genericCalculate i k = let n = fromInt i in k n Going back to reality, fromInt can't be implemented, but genericCalculate probably can, since it doesn't involve calculating a type. 19.11.2010 10:25, Arnaud Bailly пишет: Just after hitting the button send, it appeared to me that fromInt was not obvious at all, and probably impossible. Not sure I understand your answer though: What would be the second parameter (forall n . (Nat n) = n - r) - r) ? Thanks Arnaud On Fri, Nov 19, 2010 at 1:07 AM, Daniel Peeblespumpkin...@gmail.com wrote: The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Baillyarnaud.oq...@gmail.com wrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselinkhessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Baillyarnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Musings on type systems
There's a lot of interesting material on this stuff if you start poking around :) http://www.cs.kent.ac.uk/people/staff/sjt/TTFP/ might be a good introduction. I'd consider typeclasses to be sets of types, as you said, but more generally, a relation of types. In that view, an MPTC is just an n-ary relation over types. Yes, you can get arbitrarily deep on the hierarchy of types and kinds. Agda does this, and even lets you define things that are polymorphic on the universe level. If you do read through TTFP, you might want to follow along with Agda, as it fits quite nicely. On Fri, Nov 19, 2010 at 4:05 PM, Andrew Coppin andrewcop...@btinternet.comwrote: OK, so how do types actually work? Musing on this for a moment, it seems that declaring a variable to have a certain type constrains the possible values that the variable can have. You could say that a type is some sort of set, and that by issuing a type declaration, the compiler statically guarantees that the variable's value will always be an element of this set. Now here's an interesting thought. Haskell has algebraic data types. Algebraic because they are sum types of product types (or, equivilently, product types of sum types). Now I don't actually know what those terms mean, but proceeding by logical inferrence, it seems that Either X Y defines a set that could be described as the union or sum of the types X and Y. So is Either what is meant by a sum type? Similarly, (X, Y) is a set that could be considered the Cartesian product of the sets X and Y. It even has product in the name. So is this a product type? So not only do we have types which denote sets of possible values, but we have operators for constructing new sets from existing ones. (Mostly just applying type constructors to arguments.) Notionally (-) is just another type constructor, so functions aren't fundamentally different to any other types - at least, as far as the type system goes. Now, what about type variables? What do they do? Well now, that seems to be slightly interesting, since a type variable holds an entire type (whereas normal program variables just hold a single value), and each occurrance of the same variable is statically guaranteed to hold the same thing at all times. It's sort of like how every instance of a normal program variable holds the same value, except that you don't explicitly say what that value is; the compiler infers it. So what about classes? Well, restricting ourselves to single-parameter classes, it seems to me that a class is like a *set of types*. Now, interestingly, an enumeration type is a set of values where you explicitly list all possible values. But once defined, it is impossible to add new values to the set. You could say this is a closed set. A type, on the other hand, is an open set of types; you can add new types at any time. I honestly can't think of a useful intuition for MPTCs right now. Now what happens if you add associated types? For example, the canonical class Container c where type Element c :: * We already have type constructor functions such as Maybe with takes a type and constructs a new type. But here we seem to have a general function, Element, which takes some type and returns a new, arbitrary, type. And we define it by a series of equations: instance Container [x] where Element [x] = x instance Container ByteString where Element ByteString = Word8 instance (Ord x) = Container (Set x) where Element (Set x) = x instance Container IntSet where Element IntSet = Int ... Further, the inputs to this function are statically guaranteed to be types from the set (class) Container. So it's /almost/ like a regular value-level function, just with weird definition syntax. Where *the hell* do GADTs fit in here? Well, they're usually used with phantom types, so I guess we need to figure out where phantom types fit in. To the type checker, Foo Int and Foo Bool are two totally seperate types. In the phantom type case, the set of possible values for both types are actually identical. So really we just have two names for the same set. The same thing goes for a type alias (the type keyword). It's not quite the same as a newtype, since then the value expressions do actually change. So it seems that a GADT is an ADT where the elements of the set are assigned to sets of different names, or the elements are partitioned into disjoint sets with different names. Hmm, interesting. At the same type, values have types, and types have kinds. As best as I can tell, kinds exist only to distinguish between /types/ and /type functions/. For type constructors, this is the whole story. But for associated types, it's more complicated. For example, Element :: * - *, however the type argument is statically guaranteed to belong to the Container set (class). In other news... my head hurts! _ So what would happen if some crazy person decided to make the kind system more like
Re: [Haskell-cafe] About Fun with type functions example
The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious data family bug
Hmm, strange. I have a project that uses data families with dozens of constructors per clause/instantiation of the type function. I use GADT syntax to define them though as they also refine one of the parameter type variables. Never had any issues with it, although I haven't tried building that project on GHC 7 yet (as some of its dependencies didn't work last time I tried), so maybe it's a new issue? On Sun, Nov 14, 2010 at 2:15 PM, Michael Snoyman mich...@snoyman.comwrote: Hey all, While trying to get a commit pushed for Yesod[1], Alexander Dunlap pointed out one of his programs didn't work with the new code. After some investigation, I was able to reproduce the bug with the following code snippet: {-# LANGUAGE TypeFamilies #-} data family Foo a data Bar = Bar data instance Foo Bar = Bar1 | Bar2 | Bar3 | Bar4 | Bar5 | Bar6 | Bar7 | Bar8 | Bar9 deriving Eq This produces: Couldn't match expected type `Main.R:FooBar' against inferred type `Foo Bar' NB: `Foo' is a type function In the first argument of `Main.$con2tag_R:FooBar', namely `a' In the expression: (Main.$con2tag_R:FooBar a) In the expression: case (Main.$con2tag_R:FooBar a) of { a# - case (Main.$con2tag_R:FooBar b) of { b# - (a# GHC.Prim.==# b#) } } The especially strange thing about this bug is that it only occurs when there are more than 8 constructors; if I remove Bar9, everything seems to work. Does anyone have experience with this occuring? Michael [1] http://docs.yesodweb.com/blog/please-break-yesod/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: typeclass namespace rational?
If I were to guess, I'd say it's because there are two major spaces in Haskell, the type level and the value level. They never interact directly (their terms are never juxtaposed) so there's not much chance for confusion. Typeclass constructors and type constructors do however live in the same space. The fact that you propose instance String String might be odd to some. It's still unambiguous, but isn't necessarily the most clear: (with higher-sorted kind polymorphism, MPTCs, type families, and GADTs) instance String String String String String where data String String String String String where String :: String String String String String :-) On Mon, Nov 15, 2010 at 10:37 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: 2 seconds after sending I realized the issue is in module exports: Module String where (String(..)) is that exporting some concrete ADT with all of its constructors or an abstract type class with all of its methods? Its too bad that Classes and ADTs overlap in export syntax and as such must share a namespace. I would much prefer Module String where (class String(..), data String(..), someOtherFunction) which I think is easier for the reader anyway. --Jonathan On Mon, Nov 15, 2010 at 8:31 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: cafe, Data Constructors and Type Constructors don't share the same namespace. You see code like the following all the time: data MyRecord = MyRecord {...} This is possible because Data Constructors are used in different parts of the code than Type Constructors so there's never any ambiguity. Type Classes, on the other hand, share the same namespace as Type Constructors. You can't define this: class String s where ... instance String String where ... instance String ByteString where ... instance String Text where ... Not that I'm running out of valid haskell identifiers or anything :P, I'm just wondering: what's the rationale behind keeping Type Classes and Type Constructors in the same namespace? I can't think of any ambiguity there would be if they each had their own namespace. And In some cases it would be convenient to be able to define both a concrete representation and an abstract one with the same name as in the String class example above. --Jonathan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Benchmark
Looks like http://www.haskell.org/cabal/FAQ.html has a description of your problem! 2010/11/3 André Batista Martins andre...@netcabo.pt Hi Johan, i already try use Criterion but i couldn't install with cabal :S i get error: cabal install criterion Resolving dependencies... cabal: dependencies conflict: ghc-6.12.1 requires array ==0.3.0.1 however array-0.3.0.1 was excluded because ghc-6.12.1 requires array ==0.3.0.0 Anyone can help? No dia 3 de Novembro de 2010 16:33, Johan Tibell johan.tib...@gmail.comescreveu: Hi André, Have a look at the Criterion benchmarking package: http://hackage.haskell.org/package/criterion Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Current thinking on CompositionAsDot issue in haskell prime?
Speaking of MagicHash, is it really necessary to take an operator with potential like (#) just to keep primitive symbols separate from the rest? At least from my 2010 Haskell learner perspective, it seems odd to create a whole language extension/lexical change just for that purpose. On Thu, Oct 28, 2010 at 10:20 PM, wren ng thornton w...@freegeek.orgwrote: On 10/28/10 10:42 AM, Ben Millwood wrote: Here's the wiki page: http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot Personally I think function composition is what Haskell is all about and it is absolutely essential that the syntax for it be lightweight. If we think using . as qualification as well as composition is confusing, I'm much more inclined to say using it as qualification was a mistake. The comment on the wiki page about $ being more common in reality is not even close to true for my own code, and I don't think I'm unusual in that regard. Agreed on both counts. Personally, I'd much rather have name qualification and record selection use a different character than to remove (.) as composition. And replacing (.) with some abomination like `o` is unthinkable. As for the selector character, I'm partial to # but that would clash with MagicHash. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Monads and Functions sequence and sequence_
That is a result of the implementation of the specific Monad instance, and that does depend on the type, as you say (but it isn't determined for sequence(_) specifically). Nothing = f = Nothing Just x = f = f x is why a Nothing pollutes the sequenced lists of Maybes. If Maybe is a Monad representing computations that can fail (to produce a result), then if you sequence a bunch of such computations together, if any one computation fails, your entire computation fails. This reflects the natural behavior of the Maybe monad, where if you use x - maybe computation, the only way to produce that x is if the computation returned Just. In other monads, sequence will behave in the right way for that monad. On Sat, Oct 30, 2010 at 1:30 AM, Mark Spezzano mark.spezz...@chariot.net.au wrote: Not exactly. If you use the type with Maybe Int like so: sequence [Just 1, Nothing, Just 2] then the result is Nothing. Whereas sequence [Just 1, Just 2, Just 3] gives Just [1, 2, 3] Why? I assume there's special implementations of sequence and sequence_ depending on the type of monad used. If it's a sequence_ [putStrLn hello, putStrLn goodbye] then this prints out hello and goodbye on separate lines. It seems to work differently for different types. Mark On 30/10/2010, at 3:42 PM, Bardur Arantsson wrote: On 2010-10-30 07:07, Mark Spezzano wrote: Hi, Can somebody please explain exactly how the monad functions sequence and sequence_ are meant to work? I have almost every Haskell textbook, but there's surprisingly little information in them about the two functions. From what I can gather, sequence and sequence_ behave differently depending on the types of the Monads that they are processing. Is this correct? Some concrete examples would be really helpful. sequence [m1,m2,m3,m4,...] = do x1 - m1 x2 - m2 x3 - m3 x4 - m4 ... return [x1,x2,x3,x4,...] sequence_ [m1,m2,m3,m4,...] = do m1 m2 m3 m4 ... return () Cheers, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] who's in charge?
There is this one posters who likes to repeatedly point out how none of his programs ever needed email, so how could it be a problem then. Well good for him, but in my experience it's needed. This is the main issue I think people had with your original posts. You say good for him, but I need it now, and others have said (approximately, with varying niceness) we're sorry for you, but we haven't need it so far. You may have had words put in your mouth, but suggesting that the community's approach isn't working (your actual words) simply because something _you_ need isn't available (or of sufficient quality to you) is bound to cause some hostility. Saying something along the lines of: I noticed that there isn't a fully functional mail library on par with X in language Y, and need one for project Z (insert motivating description here). I think this is a useful library because applications A, B, C could all benefit from it, and we may attract users from other languages too. I had a friend who told me he didn't use Haskell for his latest project because it had no mail library, too. Would anyone be interested in a project for a full-featured mail library? I don't think I'm capable of writing the whole thing myself, but I've started a github project at URL and would be happy to collaborate in IRC channel #channel on freenode. Would have resulted in a very different response. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Need programming advice for Network Protocol Parsing
I'm occasionally working on making a friendly yet performant library that simultaneously builds parsers and generators, but it's non-trivial. If you want to see the general idea, there's a Functional Pearl on pickler combinators from a few years back that you can probably play with. But for a real network protocol that you need to implement today, I'd go with attoparsec or Data.Binary. 2010/10/27 Günther Schmidt gue.schm...@web.de Hi all, I'd like to write a client app that communicates with a server over TCP/IP. My question is in regard which parser to use for the servers responses. I'm quite familiar with parsec (2.x) but I'm not sure if it's the right choice for this. The code would necessarily constantly be switching between checking for input, interpreting and then responding. Any suggestions? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector-space and standard API for vectors
Just out of curiosity, why do you (and many others I've seen with similar proposals) talk about additive monoids? are they somehow fundamentally different from multiplicative monoids? Or is it just a matter of notation? When I was playing with building an algebraic hierarchy, I picked a neutral operator for my monoids (I actually started at magma, but it's the same thing) and then introduced the addition and multiplication distinction at semirings, as it seemed pointless to distinguish them until you have a notion of a distributive law between the two. On Fri, Oct 22, 2010 at 9:11 PM, wren ng thornton w...@freegeek.org wrote: On 10/22/10 8:46 AM, Alexey Khudyakov wrote: Hello everyone! It's well known that Num Co type classes are not adequate for vectors (I don't mean arrays). I have an idea how to address this problem. Conal Elliott wrote very nice set of type classes for vectors. (Definition below). I used them for some time and quite pleased. Code is concise and readable. class AdditiveGroup v where zeroV :: v (^+^) :: v - v - v negateV :: v - v [...] I'd like to know opinion of haskellers on this and specifically opinion of Conal Eliott as author and maintainer (I CC'ed him) Just my standard complaint: lack of support for semirings, modules, and other simple/general structures. How come everyone's in such a hurry to run off towards Euclidean spaces et al.? I'd rather see, class Additive v where -- or AdditiveMonoid, if preferred zeroV :: v (^+^) :: v - v - v class Additive v = AdditiveGroup v where negateV :: v - v type family Scalar :: * - * class Additive v = LeftModule v where (*^) :: Scalar v - v - v class Additive v = RightModule v where (^*) :: v - Scalar v - v ... Though I don't know how much that'd affect the niceness properties you mentioned. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskellers.com skills list moderation?
Hi all, Might it be worthwhile to take the elected superusers on haskellers.comand let them police the skills list? It's become rather messy, with overly broad terms like Mathematics in it, as well as overly specific ones like Other languages I know: C# .NET, XSLT, Microsoft SQL Server, XML, SQL, CSS, C, C++, Java, HTML, Visual Basic Script, Pascal, Rexx, Basic and assembler. Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Finite but not fixed length...
One option could be something like: data Z data S n data Vec n a where Nil :: Vec Z a Cons :: a - Vec n a - Vec (S n) a data Length n where One :: Length (S Z) Two :: Length (S (S Z)) Seventeen :: Length (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Z) data FixedVec a where FixedVec :: Legnth n - Vec n a - FixedVec a But it's obviously rather cumbersome :) On Wed, Oct 13, 2010 at 7:57 AM, Jason Dusek jason.du...@gmail.com wrote: Is there a way to write a Haskell data structure that is necessarily only one or two or seventeen items long; but that is nonetheless statically guaranteed to be of finite length? -- Jason Dusek Linux User #510144 | http://counter.li.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Helper
Is the language secret? because I'm sure lots of people would like to help on this mailing list, but you'd need to tell us what help you need first :) On Sun, Oct 3, 2010 at 8:38 PM, Eduardo Ribeiro asaferibei...@ymail.comwrote: Hello, I 'm developing a new language in haskell and I need someone to help me. Anyone would like to help? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell list on Twitter?
Several haskellers have lists of haskellers, and most of them include Don, I'd expect. I know my list does: http://twitter.com/#!/copumpkin/haskell Otherwise, there's a list of haskellers on the haskell wiki but I'm not usure it's very up to date: http://www.haskell.org/haskellwiki/Twitter On Fri, Oct 1, 2010 at 12:23 PM, Magnus Therning mag...@therning.orgwrote: On Fri, Oct 1, 2010 at 11:15, Vo Minh Thu not...@gmail.com wrote: 2010/10/1 Magnus Therning mag...@therning.org: Now that there are lists/groups on Twitter (http://mashable.com/2009/11/02/twitter-lists-guide/) maybe one should be created one for Haskellers? I would do it, but it seems I can't be on my own list :-) So unless I've missed something I'd have to create a dummy user just for this purpose. Hence I'm asking first :-) Hi, Is this what you're talking about? https://twitter.com/#!/donsbot/haskellers Yes, but the problem with that list is that the owner (donsbot) isn't on the list and I'd argue that no list of haskellers is complete with out Don ;-) /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell list on Twitter?
Also, it is possible to add yourself to your own twitter list :) On Fri, Oct 1, 2010 at 12:03 PM, Magnus Therning mag...@therning.orgwrote: Now that there are lists/groups on Twitter (http://mashable.com/2009/11/02/twitter-lists-guide/) maybe one should be created one for Haskellers? I would do it, but it seems I can't be on my own list :-) So unless I've missed something I'd have to create a dummy user just for this purpose. Hence I'm asking first :-) Cheers, M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell list on Twitter?
I try to keep my list up to date with new haskellers I find on twitter, and it should include everyone on the haskell wiki list. Yes, it contains me, too :) But Don's list looks like it has more people in it, so that might be better to make into a canonical one. Now I wish I had a list difference feature in twitter to figure out who's on his list and isn't on mine (and maybe vice versa). On Fri, Oct 1, 2010 at 5:04 PM, Magnus Therning mag...@therning.org wrote: On Fri, Oct 1, 2010 at 14:14, Daniel Peebles pumpkin...@gmail.com wrote: Several haskellers have lists of haskellers, and most of them include Don, I'd expect. I know my list does: http://twitter.com/#!/copumpkin/haskell Otherwise, there's a list of haskellers on the haskell wiki but I'm not usure it's very up to date: http://www.haskell.org/haskellwiki/Twitter Does your list contain all the people on the haskell wiki list? Are you on your own list? Basically, I'd like to find a single list, that someone attempts to keep up-to-date (as much as that can be done). If no one already has such a list, would it be a useful thing? /M On Fri, Oct 1, 2010 at 12:23 PM, Magnus Therning mag...@therning.org wrote: On Fri, Oct 1, 2010 at 11:15, Vo Minh Thu not...@gmail.com wrote: 2010/10/1 Magnus Therning mag...@therning.org: Now that there are lists/groups on Twitter (http://mashable.com/2009/11/02/twitter-lists-guide/) maybe one should be created one for Haskellers? I would do it, but it seems I can't be on my own list :-) So unless I've missed something I'd have to create a dummy user just for this purpose. Hence I'm asking first :-) Hi, Is this what you're talking about? https://twitter.com/#!/donsbot/haskellers Yes, but the problem with that list is that the owner (donsbot) isn't on the list and I'd argue that no list of haskellers is complete with out Don ;-) /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ultra-newbie Question
Have we put off the ultra-newbie by derailing his simple question into a discussion on subtle issues he shouldn't care about this early on? On Mon, Sep 20, 2010 at 3:49 PM, Daniel Fischer daniel.is.fisc...@web.dewrote: On Monday 20 September 2010 15:20:53, James Andrew Cook wrote: On Sep 20, 2010, at 5:10 AM, Jean-Marie Gaillourdet wrote: Hi Alberto, On 20.09.2010, at 10:53, Alberto G. Corona wrote: 2010/9/18 Daniel Fischer daniel.is.fisc...@web.de n_lastn n = reverse . take n . reverse Which is the most elegant definition, but it's an O(length list) space operation (as are all others proposed so far). T No!. You forget laziness!. it is 0(n) with n= the parameter passed to n_lastn. It is not O(length list). the reversed and de-reversed elements are just the ones being taken , not the whole list. (please kill me if I´m wrong. I don´t want to live in a world where beauty is inneficient) I am afraid you are argumentation is wrong. Let's see: f :: [a] - a f = head . reverse This is a function running in O(n) time, where n is the length of given list. That is, because f has to follow at least n pointers in order to reach the end of the parameter list. It might be much more expensive if the list has to be computed, because f got only a thunk to cumpute a list instead of a finished list. I don't believe he was claiming O(n) time, only O(n) space, Right. which I am inclined to believe. Your 'f' should also run in O(1) space. Alas, no. At least with GHC (and I don't see how it could be otherwise), reverse is always an O(length xs) space operation. reverse :: [a] - [a] #ifdef USE_REPORT_PRELUDE reverse = foldl (flip (:)) [] #else reverse l = rev l [] where rev [] a = a rev (x:xs) a = rev xs (x:a) #endif Both, the report-reverse and the other version, build the reversed list as an accumulation parameter of a tail-recursive function. The entire reversed list is returned in one piece once the end is reached. The only way to make functions using reverse run in less than O(length xs) space is, as far as I know, using rewrite rules (e.g. head . reverse = last). In general, there can be no function depending in any way on the location of the end of the list that isn't O(length list) time, because if nothing else the end of the list must be discovered, which requires that much time no matter what the algorithm. Lazyness helps helps to reduce work if your input list is lazily constructed and your function forces the returned element. Then you don't have to force all elements of the list, only the last one. Let's say l = [e_0, ..., e_n]. All the e_i are expensive calculations. g :: [a] - a g xs = x `seq` x where x = head (reverse xs) Can x `seq` x have any different strictness than just plain x? No, x `seq` x is exactly equivalent to x. I may be wrong, but I don't think so. Essentially, it's saying that when x is needed, evaluate x to WHNF and then return x. Exactly. In x `seq` y, the seq forces evaluation of x to WHNF precisely if/when y has to be evaluated to WHNF. -- James ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Idea for hackage feature
As we were discussing in #haskell, it would have to be more involved than just a taint bit. A listing showing the taint sources of a given package would give you confidence in its good behavior. For example, if my nice, pure package's taint list showed that my only taint sources were through my dependencies on base and bytestring, people could trust my program not to launch missiles behind their backs. This would essentially involve traversing transitive dependencies and looking for any module that imports one of the unsafe modules and uses any function from them (including GHC.Prim). This seems like it could be done fairly efficiently, if you just try to do it on the module or package level. At the function level, it would be a lot more computationally intensive, but would be more or less the same idea. I like the idea, but I don't think any formal proof of unsafeness is feasible. We already can't prove arbitrary properties about even our pure code, and proving stuff about impure code would require modeling the outside world and proving your code safe under that model. Anyone reading the proof would have to accept your model of the outside world as well as verifying your proof. But maybe one day we'll have way more than just Stability: experimental; Version: 0.0.1 on hackage, but instead: Stability: experimental Version: 0.0.1 Test coverage: 98% User stability rating: 86% User API quality rating: 56% Local sources of impurity: none Transitive sources of impurity: bytestring, base Used by: 37 packages [click to see them] But that's just a dream, and the impurity measures seem like a decent goal in the mean time :) Dan On Thu, Sep 16, 2010 at 8:21 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 September 2010 16:04, Mitar mmi...@gmail.com wrote: Hi! I just got an idea for hackage feature. All functions/modules listed there could have some mark if they or any function/module they use uses an unsafe* function. Of course this will make probably almost everything marked as unsafe, but this is the idea - to raise awareness about that so that you can prefer some function/implementation over another. Of course marking/tagging everything as unsafe is not really useful. Because of this I propose that then community votes/vouches on correctness/stability of implementations and this would then influence the how unsafe given function really is (or is according to community, if we are more precise). Of course it would be even better that every function using unsafe would have also a formal proof but as we cannot believe that we will prove everything in a feasible feature we could maybe opt for such crowd intelligence approach. We cannot have a Turing machine, but maybe we can have crowd. ;-) (Of course low number of found bugs and good unit test code coverage can then positively influence crowd, so authors would be motivated to assure that.) Comments? Opinions? Because I really hate that I try to keep my code pure and separate IO from everything else and then somewhere deep in there some unsafe* lurks. (Ah, yes, a side effect of this tagging/marks would be also that you would be able to see where all those unsafe* calls are for a given function, so you would be able to fast jump (with link) to a given line in code and evaluate circumstances in which that unsafe* call is made. And then vote/vouch once you discover that it is probably pretty safe.) The problem with this is: unsafe* functions would be better called yesIGuaranteeThatUsingThisFunctionDoesResultInAReferentiallyTransparentEntityAndItsOKForMeToUseIt*. They are unsafe in that you shouldn't use them blindly. Seeing as how lazy IO relies on various unsafe* functions, as do bytestrings, this means that any program that uses them is subsequently tainted. A much better idea would be to have some kind of compilation warning unless you can prove that you're using the unsafe* function in a safe fashion, but such a proof is unlikely to be easily proven in a rigorous fashion nor mechanically checkable (and would delay compilation times). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Idea for hackage feature
Yeah, those other things were part of the bigger picture that I hope hackage will get some day: two axes of user rating, plus optional support for visualizing things like test coverage and regression tests that you include in your cabal file (cabal test was being worked on during one of this year's GSOC for example). I was just trying to show what this would get us one step closer to :P On Thu, Sep 16, 2010 at 11:47 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 September 2010 17:00, Daniel Peebles pumpkin...@gmail.com wrote: But maybe one day we'll have way more than just Stability: experimental; Version: 0.0.1 on hackage, but instead: Stability: experimental Version: 0.0.1 Test coverage: 98% User stability rating: 86% User API quality rating: 56% Local sources of impurity: none Transitive sources of impurity: bytestring, base Used by: 37 packages [click to see them] But that's just a dream, and the impurity measures seem like a decent goal in the mean time :) Problem is: whilst we might be able to derive the impurity stuff, and the usage is done by examing reverse dependencies, I'm not sure how you would categorise the stability and quality. Furthermore, the test coverage bit presumably requires developers enable hpc when building tests, and if those tests are optional then wouldn't HPC's figures be slightly off since the test suite is now included in the amount of source you have compared to what most people see? Dan On Thu, Sep 16, 2010 at 8:21 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 16 September 2010 16:04, Mitar mmi...@gmail.com wrote: Hi! I just got an idea for hackage feature. All functions/modules listed there could have some mark if they or any function/module they use uses an unsafe* function. Of course this will make probably almost everything marked as unsafe, but this is the idea - to raise awareness about that so that you can prefer some function/implementation over another. Of course marking/tagging everything as unsafe is not really useful. Because of this I propose that then community votes/vouches on correctness/stability of implementations and this would then influence the how unsafe given function really is (or is according to community, if we are more precise). Of course it would be even better that every function using unsafe would have also a formal proof but as we cannot believe that we will prove everything in a feasible feature we could maybe opt for such crowd intelligence approach. We cannot have a Turing machine, but maybe we can have crowd. ;-) (Of course low number of found bugs and good unit test code coverage can then positively influence crowd, so authors would be motivated to assure that.) Comments? Opinions? Because I really hate that I try to keep my code pure and separate IO from everything else and then somewhere deep in there some unsafe* lurks. (Ah, yes, a side effect of this tagging/marks would be also that you would be able to see where all those unsafe* calls are for a given function, so you would be able to fast jump (with link) to a given line in code and evaluate circumstances in which that unsafe* call is made. And then vote/vouch once you discover that it is probably pretty safe.) The problem with this is: unsafe* functions would be better called yesIGuaranteeThatUsingThisFunctionDoesResultInAReferentiallyTransparentEntityAndItsOKForMeToUseIt*. They are unsafe in that you shouldn't use them blindly. Seeing as how lazy IO relies on various unsafe* functions, as do bytestrings, this means that any program that uses them is subsequently tainted. A much better idea would be to have some kind of compilation warning unless you can prove that you're using the unsafe* function in a safe fashion, but such a proof is unlikely to be easily proven in a rigorous fashion nor mechanically checkable (and would delay compilation times). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Web development work
Sounds awesome! Why not grab .org too? or was that taken? On Thu, Sep 16, 2010 at 2:35 PM, Michael Snoyman mich...@snoyman.comwrote: On Thu, Sep 16, 2010 at 10:26 AM, Andrew Coppin andrewcop...@btinternet.com wrote: On 16/09/2010 08:52 AM, Michael Snoyman wrote: future it would be beneficial to the community to have this information centralized on a website. I think it would be useful to have some basic skills and experience information, including system administration abilities. [..] (And yes, given the frequency with which this gets asked, we should probably write this info down somewhere!) OK, I'll bite on this one. I just registered the domain name haskellers.com (I was surprised it was available). So let me ask the community what information they would want out there. Here's the ideas I had: * Users can create their own profiles. Profiles have the following information: * Basic name, contact, website, photo, etc. * Brief bio * Skills. We'll probably have a list of skills to choose from. * Notable projects worked on, with strong focus on Hackage packages. * Some kind of web of trust feature, where users can confirm that someone else's profile is accurate. Open to suggestions on this. * A public message board for posting job information. I think this would not require login to post, but we would have spam protection (recaptcha). And then of course the basic what is Haskell, links to haskell.org, etc. I'll probably be able to get started on this early next week. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] circular imports
I was under the impression that the main reason GHC requires .hs-boot files is that nobody has had the time or inclination to make it resolve circular dependencies automatically, and not an intentional design decision to encourage good design. On Tue, Sep 7, 2010 at 6:51 AM, Mathew de Detrich dete...@gmail.com wrote: I had the same issue zonks ago, and I resorted to using the hs-boot file method as well (which worked fine) Which I guess brings me to my second point, is this something that GHC should do automatically when it sees circular dependencies? When I asked about it earlier on #haskell, I was told that its better that way because it discourages making bad design through circular dependencies (yet in my case and I assume the other cases as well, not using the hs-boot method would have made the design much worse). Are there any cases in particular where people would be encouraged to make interface design with circular dependencies (and that design be deemed as horrible) as opposed to what seems to be more realistic case where circular dependencies rarely crop up, and when they do they actually make the design better? On Tue, Sep 7, 2010 at 1:48 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 7 September 2010 03:44, Edward Z. Yang ezy...@mit.edu wrote: Excerpts from Evan Laforge's message of Mon Sep 06 13:30:43 -0400 2010: I feel like the circular imports problem is worse in haskell than other languages. Maybe because there is a tendency to centralize all state, since you need to define it along with your state monad. But the state monad module must be one of the lower level ones, since all modules that use it must import it. However, the tendency for bits of typed data to migrate into the state means it's easy for it to eventually want to import one of its importers. And the state monad module gets larger and larger (the largest modules in my system are those that define state monads: 1186 lines, 706 lines, 1156 lines---the rest tend to be 100--300 lines). I have used hs-boot files to this effect. I separated data and functionality, and typeclasses, which must be in the same module as data or are considered orphaned, get definitions via a circular import. I'm just getting to the point where I have a similar problem. I was thinking about splitting instances off from the classes (and telling GHC to not worry about orphaned instances for the instance-only modules) but then realised that some instance declarations would be circular as well, so I have to either use hs-boot files, define everything in one big module and then re-export them in ways that make sense or define all instances in one big module (at least for those types which have circular deps among instances) and re-export accordingly. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] creating a type based on a string
What you're asking for is essentially a dependent type (something where a type depends on a value). Haskell doesn't support these, but can approximate them with GADTs: {-# LANGUAGE GADTs, EmptyDataDecls, KindSignatures, Rank2Types #-} data A data B -- The data constructors refine the type index data X :: * - * where A :: X A B :: X B -- We can't return a different type based on the input string (unless you represent the string as some complex GADT that itself refines the output type), so instead we have a pseudo-existential type represented as a polymorphic function parameter. -- This basically says, if you give me a string and a function that can work on X n for all values of n, I'll give you something of the same type as the return value of that function op :: String - (forall n. X n - r) - r op a f = f A op b f = f B If you give a more detailed example of what you need, we might be able to tell you better approaches, though. This rank-2/existential approach is mostly useful for preserving internal (hidden from the end-user) type-level constraints on GADT indices. On Thu, Sep 2, 2010 at 10:31 PM, Andrew U. Frank fran...@geoinfo.tuwien.ac.at wrote: I have a user input (string) and need to select one of two types. depending what the input is. is this possible? data A data B data X n = X String op :: String - X n op a = X a :: X A op b = X b :: X B this does obviously not compile. is there a way to achieve that the type X A is produced when the input is a and X B when the input is b? thank you for help! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Crypto-API is stabilizing
Is there a reason this belongs under the Data. prefix? Why not break it out into Crypto, so future implementers of algorithms can also put their stuff under there. Everything at some level can be seen as Data, and it would be nice to start moving out of the overcrowded module hierarchy. On Fri, Sep 3, 2010 at 1:59 AM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: On Thu, Sep 2, 2010 at 3:07 PM, Sebastian Fischer s...@informatik.uni-kiel.de wrote: data Key = Key { encrypt :: B.ByteString - B.ByteString, decrypt :: B.ByteString - B.ByteString, keyLength :: BitLength, serialize :: B.ByteString} rsa :: RandomGen g = BitLength - g - ((Key,Key), g) One reason against this is simply that all the other constructs (block/stream cipher, hashes) are classes, it would be odd for there to be a single exception. A better reason is the data structure has no way to implement generateKeyPair. Why not use generateKeypair :: MonadRandom m = BitLength - m (Maybe (p,p)) Because MonadRandom dictates mtl, and is heavier weight than a single class. I was hoping to keep this agnostic (mtl is only required for testing or benchmarks in crypto-api). If MR the more agreeable path then I'll do it, though this means I use the unholy fail function. Even if that's the case (and more people weighing in would help) I still want to include Data.Crypto.Random and welcome comments. Cheers, Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Higher-order algorithms
Interesting. I've come across this general idea/algorithm the factor graph / sum-product algorithm papers[1] but I was wondering if you knew of any implementations of it in haskell? I wrote one a while back but it was fairly ugly and not as general as I'd have liked, so I never released it. Thanks, Dan [1] http://cba.mit.edu/events/03.11.ASE/docs/Loeliger.pdf On Tue, Aug 24, 2010 at 9:25 AM, wren ng thornton w...@freegeek.org wrote: On 8/24/10 12:29 AM, wren ng thornton wrote: All of these are the same algorithm, just with different (augmented) semirings. In order to prevent underflow for very small probabilities, we usually run these algorithms with probabilities in the log-domain. Those variants are also the same algorithm, just taking the image of the semiring under the logarithm functor: Forward : FW ([0,1], +, 0, *, 1) Technically, the semiring is (E, +, 0, *, 1) where E is an event space, + is union of events[1], 0 is the impossible event, * is intersection of events[2], and 1 is the event of certainty. But we can simplify things from the event space to a probability space, given the assumptions made by the forward algorithm. Just in case anyone cared :) [1] Pr(x) + Pr(y) = Pr(x) + Pr(y) - Pr(x,y) [2] Pr(x) * Pr(y) = Pr(x,y) -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GADT and problems with rigid type variables
The problem is that you have an existential `t` there, and two values of the type Foo might not have the same `t` inside them. What do you want to happen if someone writes Foo True == Foo yep? The only real solution here is to parametrize your Foo type by the t that lives within it, so you can ensure the inner types are the same. You could also do some (in my opinion) fairly nasty stuff with Dynamic or Typeable, adding a constraint to the Eq and attempting to cast at runtime (returning False if the cast returns Nothing). Hope this helps! On Mon, Aug 23, 2010 at 12:36 AM, Markus Barenhoff al...@alios.org wrote: Hello, playing with GADTs I ran into a problem with rigid type variables which is ilustrated by the following example. I think it should be pretty clear what I'am trying to express... Any suggestions? snip {-# LANGUAGE GADTs #-} data Foo where Foo :: (Eq t) = t - Foo instance Eq Foo where (Foo a) == (Foo b) = a == b {- Scratch.hs:7:28: Couldn't match expected type `t' against inferred type `t1' `t' is a rigid type variable bound by the constructor `Foo' at /home/alios/src/lab/Scratch.hs:7:3 `t1' is a rigid type variable bound by the constructor `Foo' at /home/alios/src/lab/Scratch.hs:7:14 In the second argument of `(==)', namely `b' In the expression: a == b In the definition of `==': (Foo a) == (Foo b) = a == b Failed, modules loaded: none. -} snip thnx Markus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: String vs ByteString
Sounds to me like we need a lazy Data.Text variation that allows UTF-8 and UTF-16 segments in it list of strict text elements :) Then big chunks of western text will be encoded efficiently, and same with CJK! Not sure what to do about strict Data.Text though :) On Tue, Aug 17, 2010 at 1:40 PM, Ketil Malde ke...@malde.org wrote: Michael Snoyman mich...@snoyman.com writes: As far as space usage, you are correct that CJK data will take up more memory in UTF-8 than UTF-16. With the danger of sounding ... alphabetist? as well as belaboring a point I agree is irrelevant (the storage format): I'd point out that it seems at least as unfair to optimize for CJK at the cost of Western languages. UTF-16 uses two bytes for (most) CJK ideograms, and (all, I think) characters in Western and other phonetic scripts. UTF-8 uses one to two bytes for a lot of Western alphabets, but three for CJK ideograms. Now, CJK has about 20K ideograms, which is almost 15 bits per ideogram, while an ASCII letter is about six bits. Thus, the information density of CJK and ASCII is about equal for UTF-8, 5/8 vs 6/8 - compared to 15/16 vs 6/16 for UTF-16. In other words a given document translated between Chinese and English should occupy roughly the same space in UTF-8, but be 2.5 times longer in English for UTF-16. -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question about memory usage
There's a Fibonacci Heap: http://en.wikipedia.org/wiki/Fibonacci_heap Not sure what else though :) On Mon, Aug 16, 2010 at 11:14 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Aug 16, 2010 at 1:37 PM, Andrew Coppin andrewcop...@btinternet.com wrote: This neatly leads us back to my second assertion: In all my years of computer programming, I've never seen one single program that actually *needs* the Fibonacci numbers in the first place (let alone in arbitrary-precision). I think there are variants on AVL trees that use something related to a Fibonacci sequence for balancing. I don't remember the details, though. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question about memory usage
In the example above, fiblist is a global variable, so the answer to when does it get freed? would be never. (I believe it's called a CAF leak.) Is that actually true? I've heard lots of references to this, but I'm not sure it is true. Sure, it's harder for it to get collected when everyone can potentially access it, but the mechanisms for checking who holds pointers to a value are still valid for CAFS, and collection can still work on them, I think. The commentary at http://is.gd/ehEuL seems to suggest that CAFs can be garbage collected, too. My apologies for confusing the issue, if this is not correct, though! Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] universal quantification is to type instantiations as existential quantification is to what
The existential is a pair where one component is a type, and the type of the second component depends on the value (i.e., which type went in the first component) of the first. It's often called a sigma type when you have full dependent types. So your exists a. (Int - a) - [Int] - [a] type might hypothetically be represented as (assuming you write an instance for Bool): (*, (\a - (Int - a) - [Int] - [a])) -- the type, where * is the kind of types (Bool, some function of type (Int - Bool) - [Int] - [a]) You can translate to and from forall and exists by currying, since one is a function and the other is a pair, but not in the form you asked. It'd look a lot more like curry/uncurry in regular haskell :) Hope I wasn't too unclear! Dan On Thu, Aug 12, 2010 at 7:32 PM, Joshua Ball scioli...@gmail.com wrote: Hi, If I have a universally quantified type mapInt :: forall a. (Int - a) - [Int] - [a] I can instantiate that function over a type and get a beta-reduced version of the type mapInt [String] :: (Int - String) - [Int] - [String] (I'm borrowing syntax from Pierce here since I don't think Haskell allows me to explicitly pass in a type to a function.) This makes sense to me. The universal quantifier is basically a lambda, but it works at the type level instead of the value level. My question is... what is the analog to an existential type? mapInt :: exists a. (Int - a) - [Int] - [a] (I don't think this is valid syntax either. I understand that I can rewrite this using foralls and a new type variable, doing something that looks like double negation, but the point of my question is to get an intuition for what exactly the universal quantifier means in the context of function application... if this even makes sense.) In particular: 1. If I can instantiate variables in a universal quantifier, what is the corresponding word for variables in an existential quantifier? 2. If type instantiation of a universally quantified variable is beta-reduction, what happens when existentially quantified variables are [insert answer to question 1]? 3. Is there any analogue to existential quantifiers in the value world? Forall is to lambda as exists is to what? Also (separate question), is the following statement true? forall T :: * - *. (forall a. T a) - (exists a. T a) If so, what does the implementation look like? (What function inhabits it, if it is interpreted as a type?) Josh Ua Ball ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
The Hummingbird is still ARM. ARM doesn't actually build any chips themselves, and just license the architecture design out to people who do make them. Most of the iPhone ARM chips are built by Samsung too. Almost all the mobile devices I know of run ARM, so I think having a native ARM generator would still be very beneficial. And if it isn't ARM on a device, it's almost certainly going to be Intel, these days. Sure, Android doesn't specify that this has to be the case, but realistically, it will be. On Sun, Aug 8, 2010 at 3:08 AM, Mathew de Detrich dete...@gmail.com wrote: Well the other issue is of course that Android being available on a wide variety of phones, not all of which run ARM (the phone I am about to get for example has a custom built CPU), although I guess one could use a generic ASM branch for mobile devices (if one exists). btw the phone I am about to receive is a Samsung Galaxy-S, which has a hummingbird chip (no idea what Assembler Instruction set it uses, I believe its a closed chip) In my opinion the most reliable approach would actually to produce the C that wraps around NDK (for any code that could be possible) which would obviously interface with the Java libraries. Probably the biggest bane of Android is the fact that its able to run on almost all machines means that there *would* be issues using LLVM to just produce code for the generic ARM. Using the NDK + Java would mean any app written in Haskell would work on any android device. Of course as mentioned above, there are issues with this. Its a lot of work for one thing, and the GC for Java is probably not the best suited for Haskell structured programs. Also iirc, in order to make official Android apps which can go on the market place, you are basically forced to use the Java API + NDK for any native code, and you have to use the Java API to interface with the android GUI/World (you can't make an proper Android app just using NDK which complicates things further). The GC issue I guess could be solved by generating JVM code (instead of Java code) which would give more freedom for GHC to generate code more suited to Haskell If this ever ended up happening, it does have the advantage that when one would develop an app for Android using Haskell, GHC (or whatever compiler we would use) can use NDK for as much code as possible and only resorting to Java libraries when required which can of course equate to creating very fast Android Apps using a productive language (Haskell) As Don mentioned through, we need a java runtime for GHC. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: DSTM 0.1.1
Another interesting direction would be to use Matt Morrow's vaccum infrastructure to make a neat, almost completely general, serialization mechanism. It's not safe, and can traverse any value that doesn't contain functions or unevaluated thunks, but would be very helpful for sending values like `cycle [1,2,3]` over the network. He and I were talking about writing such a library before he disappeared, but it doesn't seem terribly difficult if you have a good use for it. Dan On Fri, Aug 6, 2010 at 11:14 AM, Frank Kupke f...@informatik.uni-kiel.dewrote: Paul, Yes, I use Read and Show to serialize. I thought of switching to Binary myself but could not find the time yet ;-) Now, a student here is going to work on that. Also, as TCP communication involves a lot of overhead, the library makes some efforts to reduce the amount of messages and makes message exchange itself quite efficient which resulted in a significant efficiency gain. But, there is definitely more optimization potential buried... Frank Am 06.08.2010 um 00:49 schrieb Paul Johnson: Looks interesting. One point: you seem to be using Read and Show typeclasses for serialisation. I think you would be better off using Binary, which is much more efficient. Paul. On 03/08/10 09:35, Frank Kupke wrote: Hi, DSTM is an implementation of a robust distributed Software Transactional Memory (STM) library for Haskell. Many real-life applications are distributed by nature. Concurrent applications may profit from robustness added by re-implementation as distributed applications. DSTM extends the STM abstraction to distributed systems and presents an implementation efficient enough to be used in soft real-time applications. Further, the implemented library is robust in itself, offering the application developer a high abstraction level to realize robustness, hence, significantly simplifying this, in general, complex task. The DSTM package consists of the DSTM library, a name server application, and three sample distributed programs using the library. Provided are a simple Dining Philosophers, a Chat, and a soft real-time Bomberman game application. Distributed communication is transparent to the application programmer. The application designer uses a very simple name server mechanism to set up the system. The DSTM library includes the management of unavailable process nodes and provides the application with abstract error information thus facilitating the implementation of robust distributed application programs. For usage please look into the documentation file: DSTMManual.pdf. The package including the documentation can be found on:http://hackage.haskell.org/package/DSTM-0.1.1 Best regards, Frank Kupke ___ Haskell-Cafe mailing listhaskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Preview the new haddock look and take a short survey
Great! I like it a lot, but a couple of minor suggestions regarding the tree view of modules. I think it would be more attractive (and space-efficient) to have them indent a little less and to provide some sort of visual link, in the form of even subtle branches, from parents to children. A bit like http://origin.arstechnica.com/journals/linux.media/300/dolphin_tree_view.pngor similar. On Wed, Aug 4, 2010 at 7:00 AM, Mark Lentczner ma...@glyphic.com wrote: The Haddock team has spent the last few months revamping the look of the generated output. We're pretty close to done, but we'd like to get the community's input before we put it in the main release. Please take a look, and then give us your feedback through a short survey Sample pages: http://www.ozonehouse.com/mark/snap-xhtml/index.html Frame version: http://www.ozonehouse.com/mark/snap-xhtml/frames.html Survey: http://spreadsheets.google.com/viewform?formkey=dHcwYzdMNkl5WER1aVBXdV9HX1l5U3c6MQ Short link to same survey: http://bit.ly/9Zvs9B Thanks! - Mark Mark Lentczner http://www.ozonehouse.com/mark/ irc: MtnViewMark ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why do unsafe foreign calls block other threads?
It's a matter of perspective. Either the function you're FFI'ing to is safe/unsafe or your use of it is safe/unsafe. The FFI spec seems to be using the former, so if you think that the function you're calling is unsafe (i.e., can call back into Haskell) then it blocks the world. But I do think it's unintuitive and a less ambiguous naming scheme would be nicer. Dan On Tue, Aug 3, 2010 at 11:54 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: Hey everyone, Could someone explain to me the logic behind having unsafe calls block other threads from executing? It seems to me that if anything it would make more sense for safe calls to block other threads since the call can call back into the Haskell runtime, as opposed to unsafe calls which (by assertion) will never call back into Haskell and therefore should be safer to run in parallel with other threads. What am I missing here? Cheers, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] Re: [Haskell-cafe] Work on Video Games in Haskell
Of course, given that they have no way of determining that short of asking for the source code (and hiring another thousand reviewers to read it) or applying static analysis tools with heuristics to the programs. I really doubt they do the latter, and the former is unrealistic. Most people seem to think the clause is there mostly to discourage large companies like Adobe from making generic tools to translate to the iPhone/iPad. It would be a lot of effort for Apple to actually enforce it strictly. On Wed, May 26, 2010 at 3:58 AM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On May 26, 2010, at 03:50 , David Virebayre wrote: On Wed, May 26, 2010 at 9:23 AM, Lyndon Maydwell maydw...@gmail.com wrote: As a side note, how is this project getting around the language restrictions apple put in the developer license agreement? From the project page : This version uses Apple's official iPhone SDK as its back end compiler. You might want to reread that license agreement. Specifically: Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] Re: [Haskell-cafe] Work on Video Games in Haskell
Next up, binary obfuscation! Apple already uses these extensively in their Fairplay code. Surely it isn't against the rules (yet?) to apply them to your program before submitting it to the store? :P On Wed, May 26, 2010 at 11:01 PM, Ben Lippmeier b...@ouroborus.net wrote: On 27/05/2010, at 9:01 AM, Edward Kmett wrote: While we can all acknowledge the technical impossibility of identifying the original source language of a piece of code... Uh, desire:tmp benl$ cat Hello.hs main = putStr Hello desire:tmp benl$ ghc --make Hello.hs desire:tmp benl$ strings Hello | head Hello base:GHC.Arr.STArray base:GHC.Arr.STArray base:GHC.Classes.D:Eq base:GHC.Classes.D:Eq failed to read siginfo_t failed: Warning: select buildFdSets: file descriptor out of range ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: currying combinators
Djinn can't figure it out, and neither can I :P 2010/5/25 Günther Schmidt gue.schm...@web.de Hi Yitz, embarrassingly I was unable to deduce the implementation from the type signature, don't be tease man, show me what you got :) Günther Am 25.05.10 18:27, schrieb Yitzchak Gale: Günther Schmidt wrote: http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=25694 in which I attempt to develop a currying combinator library. I'm stuck at some point and would appreciate any help. How about this: keep :: ((t - b) - u - b) - ((t1 - t) - b) - (t1 - u) - b so then nameZip = keep (drop' . drop') names Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] making the GHC Api not write to stderr
Have you tried freopen on stderr? On Fri, May 21, 2010 at 8:43 AM, Phyx loneti...@gmail.com wrote: Hi, I tried that, setting it to (\_ _ _ _ - return ()) and it still did the same, also tried setting it to undefined to see whether the code that's printing the error is using it, and it didn't crash So I assume it's not. --- *VsxParser getModInfo True C:\\Users\\Phyx\\AppData\\Local\\Temp\\tmp5600.hs return () C:\Users\Phyx\AppData\Local\Temp\tmp5600.hs:11:13: parse error on input `=' Printf - I think parseModule might still have a hardcoded print statement in it. -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Friday, May 21, 2010 12:53 To: Phyx Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] making the GHC Api not write to stderr You could try changing the log_action[1] member of the DynFlags. A while ago I turned most printed errors into some form of error message, but I wouldn't be surprised if I missed some places. All output should go through log_action, though, so try changing that to intercept any output. [1]: http://haskell.org/ghc/docs/6.12-latest/html/libraries/ghc-6.12.2/DynFlags.h tml#v%3Alog_action On 20 May 2010 19:05, Phyx loneti...@gmail.com wrote: I was wondering how to forcibly quiet down the API. I have a custom handler in place, but when I call the function on failure both my handler gets called and somewhere somehow errors get printed to the stderr, which I really need to avoid. My current code looks like getModInfo :: Bool - String - String - IO (ApiResults ModuleInfo) getModInfo qual file path = handleSourceError processErrors $ runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags $ configureDynFlags dflags target - guessTarget file Nothing addTarget target setSessionDynFlags $ dflags { importPaths = [path] } load LoadAllTargets graph - depanal [] False let modifier = moduleName . ms_mod modName = modifier $ head graph includes = includePaths dflags imports = importPaths dflags dflags' - Debug.trace (moduleNameString modName) getSessionDynFlags setSessionDynFlags $ dflags' { includePaths = path:includes , importPaths = path:imports } parsed - parse modName checked - typecheckModule parsed ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Push the envelope. Watch it bend. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strict type system allows for a maximum number of programming errors to be caught at compile time.
prefac is just a normal factorial function with recursion factored out. fix prefac 5 gives 120, for example. On Tue, May 4, 2010 at 12:13 AM, Ivan Miljenovic ivan.miljeno...@gmail.comwrote: On 4 May 2010 13:30, Luke Palmer lrpal...@gmail.com wrote: Here is a contrived example of what I am referring to: prefac f 0 = 1 prefac f n = n * f (n-1) fac = (\x - x x) (\x - prefac (x x)) I can't work out how this works (or should work rather); is it meant to be using church numerals or something (assuming that they have been made an instance of Num so that - and * work)? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Number of CPUs/cores?
I believe numCapabilities (should be in IO, in my opinion, but that's another discussion) will tell you the number of capabilities (native threads) that have been given to the RTS. The measurement doesn't necessarily have any connection to the number of physical cores or processors in your machine. On Tue, Apr 27, 2010 at 11:05 AM, Dimitry Golubovsky golubov...@gmail.comwrote: OK, makes sense. Thank you. On Tue, Apr 27, 2010 at 10:58 AM, Michael Lesniak mlesn...@uni-kassel.de wrote: [skip] numCapabilities, I think. -- Dimitry Golubovsky Anywhere on the Web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting used and available memory
It's not an easy measurement to even define. There was a huge debacle recently about a windows program that reported misleading numbers about used memory. The fact that GHC has its own allocator and hogs OS memory (it never returns it to the OS) might complicate the definition further. But in general, if you're looking for an OS-level measure you're probably going to need to go to the FFI and talk to the specific OS's API for the task. I'm not sure if the GHC runtime allows you to ask much about allocated memory. The only thing I've done with it was FFI out to a variable that counts the number of bytes allocated to measure allocations in calls like GHCi does. On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm mads.lindstr...@gmail.comwrote: Hi I have tried haskell.org, Google and Hoolge, but I cannot find any function to give me the available and/or used memory of a Haskell program. Is it just not there? Or am I missing it somehow? /Mads ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell.org re-design
I'm definitely not a design/color person, but has anyone considered using kuler.adobe.com as a source of nice color schemes, since we seem to have an issue coming up with attractive combinations? On Tue, Apr 6, 2010 at 9:58 AM, Thomas Schilling nomin...@googlemail.comwrote: Well, they make the wannabe-designer mistake of using justified text in HTML, even worse, for columns just 3 words wide. The overall layout, is pretty nice though. It's essentially the standard Web 2.0 layout (compare http://basecamphq.com/, http://www.blinksale.com/, http://www.analysis-one.com/, etc.). The key design elements are (IMO): - Put the important stuff at the top and separate it visually from the other stuff. The important things are: (1) the quick summary of Haskell, (2) the Get Haskell button, (3) link to Learn Haskell / Try Haskell - We may have a second row/column of secondary important stuff, like community, project hosting, more implementations, the top learning materials, etc. links to Haskell users - News, Events, etc. can go further down I'm not particularly attached to any particulars of my suggested design. I just thought I'll try to encourage to move away much further from the current wiki-like and somewhat dull design. On 6 April 2010 10:36, Johan Tibell johan.tib...@gmail.com wrote: On Tue, Apr 6, 2010 at 5:24 AM, Simon Michael si...@joyful.com wrote: On 4/2/10 5:28 AM, Thomas Schilling wrote: How about something more colourful? http://i.imgur.com/7jCPq.png I really like the simplicity of the Cassandra page: http://cassandra.apache.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Push the envelope. Watch it bend. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lists of Existential DT
You can actually write that type with impredicative polymorphism, but it doesn't do what you seem to want: it makes a list of polymorphic values (i.e., universally quantified ones, not existentially). But that's going away soon, anyway... On Sun, Feb 28, 2010 at 1:49 PM, Yves Parès limestr...@gmail.com wrote: jkff wrote: Or like this, with the benefit of using lists. data DrawableObj a = forall a.Drawable a = DrawableObj a a , b = DrawableObj a : b drawMany (a,b,c,[]) I like this solution, but it's a pity I think that Haskell doesn't provide a way to use types like [forall a. (Drawable a) = a], which obligates you to declare an extra datatype... - Yves Parès Live long and prosper -- View this message in context: http://old.nabble.com/Lists-of-Existential-DT-tp27735354p27737144.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What are free Monads?
Given any functor you can get a monad for free! data Free f a = Either a (f (Free f a)) Not sure about unfree, but there are cofree comonads that are pretty closely related, and give you a comonad given a functor: data Cofree f a = (a, f (Cofree f a)) I'm sure the more categorically minded can tell you way more. Hope this helps, Dan 2010/2/27 Günther Schmidt gue.schm...@web.de Hello, I see the term free monad quite a lot, but don't really see an explanation what a free monad is. What sets a monad free and why in this day and age are there unfree monads? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] datakind declaration
It's not quite what you're asking for, but a very similar idea is the SHE preprocessor: http://personal.cis.strath.ac.uk/~conor/pub/she/ Dan On Mon, Feb 22, 2010 at 8:08 PM, Paul Brauner paul.brau...@loria.fr wrote: Hello, I remember seeing something like typedata T = A | B somewhere, where A and B are type constructors, but I can't find it in the ghc doc. Have I been dreaming or is it some hidden feature ? Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linear programming in Haskell
Interesting. Do you have any details on this? It seems like it would be hard to express system of linear inequalities as a finite system of linear equations. Thanks, Dan 2010/2/17 Matthias Görgens matthias.goerg...@googlemail.com As far as I can see, you'd use that for systems of linear equalities, but for systems of linear inequalities with a linear objective function, it's not suitable. I may be wrong though :) There's a linear [1] reduction from one problem to the other and vice versa. [1] The transformation itself is a linear function, and it takes O(n) time, too. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linear programming in Haskell
How would you use hmatrix? By linear programming I assume he means systems of linear inequalities, as typically solved by the simplex algorithm. I too am interested in this question (and the more general one of nonlinear optimization)! Thanks, Dan On Tue, Feb 16, 2010 at 2:54 PM, Felipe Lessa felipe.le...@gmail.comwrote: On Tue, Feb 16, 2010 at 01:37:54PM -0600, Louis Wasserman wrote: Is there a nice package out there somewhere with a linear programming implementation? Preferably with a nicely functional interface? hmatrix? Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linear programming in Haskell
As far as I can see, you'd use that for systems of linear *equalities*, but for systems of linear *inequalities* with a linear objective function, it's not suitable. I may be wrong though :) On Tue, Feb 16, 2010 at 3:37 PM, Felipe Lessa felipe.le...@gmail.comwrote: On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote: How would you use hmatrix? By linear programming I assume he means systems of linear inequalities, as typically solved by the simplex algorithm. I too am interested in this question (and the more general one of nonlinear optimization)! I have never used this part of hmatrix, but does Numeric.LinearAlgebra satisfy your needs? In particular, see linearSolve[1] and linearSolveR[2]. [1] http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve [2] http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack ADT?
data Stack a = EmptyStk | Stk a (Stack a) I find it amusing that the book defined a type that is exactly isomorphic to the standard list (EmptyStk === [] and Stk === (:)). I guess it's just for clarity? On Thu, Feb 4, 2010 at 12:29 PM, Casey Hawthorne cas...@istar.ca wrote: On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: Can't find a Stack datatype on Hoogle? Where should I look? Michael From Algorithms: a functional programming approach Second edition Fethi Rabhi Guy Lapalme data Stack a= EmptyStk | Stk a (Stack a) push x s= Stk x s pop EmptyStk= error pop from an empty stack pop (Stk _ s) = s top EmptyStk= error top from an empty stack top (Stk x _) = x emptyStack = EmptyStk stackEmpty EmptyStk = True stackEmpty _= False newtype Stack a = Stk [a] push x (Stk xs) = Stk (x:xs) pop (Stk [])= error pop from an empty stack pop (Stk (_:xs))= Stk xs top (Stk [])= error top from an empty stack top (Stk (x:_)) = x emptyStack = Stk [] stackEmpty (Stk []) = True stackEmpty (Stk _ ) = False -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe