Re: [Haskell-cafe] inv f g = f . g . f

2013-08-19 Thread Nikita Danilenko
Hi, as for the nomenclature - mathematically the pattern f^{-1} . g . f is sometimes called "conjugation" [1]. One (trivial) type of occurrence is data Foo a = Foo { unFoo :: a } deriving Show instance Functor Foo where fmap f = Foo . f . unFoo The under function from the lens library [2] al

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread AntC
> Brent Yorgey seas.upenn.edu> writes: > > > > data Oneple a = Oneple a -- (or newtype) > > (Oneple $ CustId 47) -- too verbose > > > > This is what the OneTuple package is for: > Thank you Brent, and Ivan made the same suggestion. Apart from b

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread Daniel F
Can you please elaborate why this inconsistency is annoying and what's the use of OneTuple? Genuine question, thanks. On Fri, Aug 16, 2013 at 5:35 AM, AntC wrote: > There's an annoying inconsistency: > > (CustId 47, CustName "Fred", Gender Male) -- threeple > (CustId 47, CustName "Fred

Re: [Haskell-cafe] ordNub

2013-08-19 Thread AntC
> Richard A. O'Keefe cs.otago.ac.nz> writes: > > There are at least four different things that "an Ord version" might > mean: > > - first sort a list, then eliminate duplicates > - sort a list eliminating duplicates stably as you go >(think 'merge sort', using 'union' instead of 'merge') >

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread adam vogt
On Mon, Aug 19, 2013 at 5:40 AM, AntC wrote: ... > Would double-parens be too wild an idea?: > > ... ((CustId 47)) `extend` (CustName "Fred", Gender Male) > > f ((CustId x)) = ... > > instance C ((CustId Int)) ... > > We'd have to avoid the double parens as in: > > ((meth obj) (dou

[Haskell-cafe] GHC and backwards compatibility

2013-08-19 Thread Ketil Malde
I recently encountered the following problem: $ cabal install Resolving dependencies... Configuring array-0.4.0.1... Building array-0.4.0.1... Preprocessing library array-0.4.0.1... Data/Array/IArray.hs:1:14: Unsupp

Re: [Haskell-cafe] GHC and backwards compatibility

2013-08-19 Thread Joe Q
This is definitely an issue with the array package not setting the right minimum versions. You should email the maintainer. On Aug 19, 2013 11:05 AM, "Ketil Malde" wrote: > > I recently encountered the following problem: > > > --

Re: [Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)

2013-08-19 Thread Kyle Miller
On Sun, Aug 18, 2013 at 8:04 PM, Richard A. O'Keefe wrote: > The argument for twos-complement, which always puzzled me, is that the > other > systems have two ways to represent zero. I never found this to be a > problem, > not even for bitwise operations, on the B6700. I *did* find "abs x < 0" >

Re: [Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)

2013-08-19 Thread Brandon Allbery
On Mon, Aug 19, 2013 at 11:43 AM, Kyle Miller wrote: > Or, three other options: 1) make MIN_INT outside the domain of abs, 2) > make the range of abs be some unsigned int type, or 3) use Integer (i.e., > use a type which actually represents integers rather than a type which can > only handle smal

[Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread jabolopes
Hi, What is the proper way to implement a non-monadic function that checks whether a given value is correct and gives a proper error message otherwise ? What is the recommended option ? * Either String a check val | valid val = Right val | otherwise = Left errorMsg * Maybe String check va

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Daniel F
On Mon, Aug 19, 2013 at 9:48 PM, wrote: > Hi, > > Hello! > What is the proper way to implement a non-monadic function that checks > whether a given value is correct and gives a proper error message > otherwise ? What is the recommended option ? > I am not sure, what do you mean by non-monadic.

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Brandon Allbery
On Mon, Aug 19, 2013 at 1:48 PM, wrote: > What is the proper way to implement a non-monadic function that checks > whether a given value is correct and gives a proper error message > otherwise ? What is the recommended option ? > > * Either String a > Preferred, usually, since Nothing is regarde

[Haskell-cafe] wxHaskell mailinglist

2013-08-19 Thread Nathan Hüsken
Hey, Anyone knows what the proper channel for reporting bugs and asking questions about wxHaskell is? The github page https://github.com/wxHaskell/wxHaskell/wiki seems to have issues disabled, and when I post to the wxHaskell user mailinglist, it tells me that the list is moderated. But my pos

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread jabolopes
Yeah, non-monadic is not the best term... The problem is that it's always so hard to communicate when you want to say a total function that is not in the context of the IO monad. There should be a simple, short name for these functions, so we can easily talk about them. What ends up happening a lo

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Brandon Allbery
On Mon, Aug 19, 2013 at 2:09 PM, Brandon Allbery wrote: > Alternatively, have you considered using your own ADT? `data Validity = > Success | Failure String` would give you more readable / comprehensible > code without needing to worry about assumptions or common usage. Or possibly Valid and Inv

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Tom Ellis
On Mon, Aug 19, 2013 at 02:20:23PM -0400, jabolo...@google.com wrote: > Yeah, non-monadic is not the best term... The problem is that it's > always so hard to communicate when you want to say a total function > that is not in the context of the IO monad. There should be a simple, > short name for t

Re: [Haskell-cafe] GHC and backwards compatibility

2013-08-19 Thread Ketil Malde
Joe Q writes: > This is definitely an issue with the array package not setting the right > minimum versions. You should email the maintainer. Yes, that would be the thing to do, except that the maintainer is "librar...@haskell.org", whom I believe does not accept emails from me. :-( But if you

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread jabolopes
I'd say that if you were in the context of the IO monad, maybe you'd prefer to use exceptions instead of 'Either' or 'Maybe'. Jose On Mon, Aug 19, 2013 at 07:41:48PM +0100, Tom Ellis wrote: > On Mon, Aug 19, 2013 at 02:20:23PM -0400, jabolo...@google.com wrote: > > Yeah, non-monadic is not the be

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Brandon Allbery
On Mon, Aug 19, 2013 at 2:59 PM, wrote: > I'd say that if you were in the context of the IO monad, maybe you'd > prefer to use exceptions instead of 'Either' or 'Maybe'. > Even in IO, exceptions should be reserved for truly exceptional conditions (of the "program cannot safely continue" variety)

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Tobias Dammers
Except that people generally don't seem to agree what constitutes 'exceptional', even when disregarding the python world... On Aug 19, 2013 9:24 PM, "Brandon Allbery" wrote: > On Mon, Aug 19, 2013 at 2:59 PM, wrote: > >> I'd say that if you were in the context of the IO monad, maybe you'd >> pre

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Donn Cave
jabolo...@google.com, MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 In-Reply-To: References: quoth Brandon Allbery, > Even in IO, exceptions should be reserved for truly exceptional conditions > (of the "program cannot safely continue" variety), not merely for error > checking when

Re: [Haskell-cafe] librar...@haskell.org (was: GHC and backwards compatibility)

2013-08-19 Thread Joe Quinn
On 8/19/2013 2:43 PM, Ketil Malde wrote: Joe Q writes: This is definitely an issue with the array package not setting the right minimum versions. You should email the maintainer. Yes, that would be the thing to do, except that the maintainer is "librar...@haskell.org", whom I believe does not

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread jabolopes
I agree that whether to use exceptions or not is a very debatable subject and it is a grey area. Still, in your Python example, I would like to point out that just because something is common, it does not mean it is the right thing to do. For example, something that some Java programmers were doi

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Tom Ellis
On Mon, Aug 19, 2013 at 05:15:39PM -0400, jabolo...@google.com wrote: > But I would like to see more code move away from exceptions and into > types like "Maybe" or "Either" or other types defined for the > particular situation (as some people were suggesting in the beginning > of the thread). And

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Patrick Mylund Nielsen
On Mon, Aug 19, 2013 at 5:24 PM, Tom Ellis < tom-lists-haskell-cafe-2...@jaguarpaw.co.uk> wrote: > On Mon, Aug 19, 2013 at 05:15:39PM -0400, jabolo...@google.com wrote: > > But I would like to see more code move away from exceptions and into > > types like "Maybe" or "Either" or other types define

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Jerzy Karczmarczuk
jabolo...@google.com : I would like to see more code move away from exceptions and into types like "Maybe" or "Either" or other types defined for the particular situation (as some people were suggesting in the beginning of the thread). And the reason for this it is because when you program agains

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread jabolopes
> Some exceptions, e.g. in the traversal of deep structures may be and > ARE used as escaping continuations. If I understand correctly, by "escaping continuations" you mean that you can easily transfer control between the point where the exception is raised and the exception handler. If this is w

Re: [Haskell-cafe] GHC and backwards compatibility

2013-08-19 Thread Albert Y. C. Lai
On 13-08-19 10:58 AM, Ketil Malde wrote: b) the output isn't very helpful in tracking down the cause of this problem, it claims that all these packages depend on array-0.4.0.1, which is a lie. Somewhere, somehow, somethings depends on this (or at least a newer version), but I have no clue how to

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Jerzy Karczmarczuk
Le 20/08/2013 00:19, jabolo...@google.com a écrit : If I understand correctly, by "escaping continuations" you mean that you can easily transfer control between the point where the exception is raised and the exception handler. If this is what you mean, you can achieve the same effect with monad

Re: [Haskell-cafe] Errors in non-monadic code

2013-08-19 Thread Tom Ellis
On Tue, Aug 20, 2013 at 12:25:44AM +0200, Jerzy Karczmarczuk wrote: > Le 20/08/2013 00:19, jabolo...@google.com a écrit : > >If I understand correctly, by "escaping continuations" you mean that > >you can easily transfer control between the point where the exception > >is raised and the exception h

[Haskell-cafe] Categories with associated constraints?

2013-08-19 Thread Conal Elliott
Has anyone given a go at a Category class and friends (including cartesian and closed) with associated constraints (presumably using the ConstraintKinds language extension)? I gave it a try a while back and wasn't able to keep the signatures from getting very complicated. Thanks, -- Conal __

Re: [Haskell-cafe] Categories with associated constraints?

2013-08-19 Thread Carter Schonwald
I've not seen such, Mike Izbicki has something related for most of the other standard classes (though i've not looked closely at it myself) http://hackage.haskell.org/package/ConstraintKinds-1.1.0.0 On Mon, Aug 19, 2013 at 6:45 PM, Conal Elliott wrote: > Has anyone given a go at a Category cla

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread AntC
> Daniel F gmail.com> writes: > > Can you please elaborate why this inconsistency is annoying and what's the use of OneTuple? > Genuine question, Hi Daniel, the main annoyance is the verbosity (of using a data type and constructor), and that it no longer looks like a tuple. The inconsistency

Re: [Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)

2013-08-19 Thread Richard A. O'Keefe
On 20/08/2013, at 3:43 AM, Kyle Miller wrote: > On Sun, Aug 18, 2013 at 8:04 PM, Richard A. O'Keefe > wrote: > The argument for twos-complement, which always puzzled me, is that the other > systems have two ways to represent zero. I never found this to be a problem, > not even for bitwise oper

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread Ivan Lazar Miljenovic
On 20 August 2013 11:07, AntC wrote: >> Daniel F gmail.com> writes: >> >> Can you please elaborate why this inconsistency is annoying and what's > the use of OneTuple? >> Genuine question, > > Hi Daniel, the main annoyance is the verbosity (of using a data type and > constructor), and that it no

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread Mike Ledger
It seems to me that this is Identity given a different name. A bonus of using Identity is that it won't introduce any new packages to the majority of installations. On 20/08/2013 1:17 PM, "Ivan Lazar Miljenovic" wrote: > On 20 August 2013 11:07, AntC wrote: > >> Daniel F gmail.com> writes: > >>

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread AntC
> Mike Ledger gmail.com> writes: > > It seems to me that this is Identity given a different name. A bonus of using Identity is that it won't introduce any new packages to the majority of installations. > > On 20/08/2013 1:17 PM, "Ivan Lazar Miljenovic" wrote: > ... > isn't a single element tup

Re: [Haskell-cafe] One-element tuple

2013-08-19 Thread Chris Wong
> It seems to me that this is Identity given a different name. Close. But Identity is declared using newtype (just like monad transformers), whereas OneTuple is declared with data (like the other tuples). This may or may not matter, depending on your use case. > > On 20/08/2013 1:17 PM, "Ivan La