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

2013-08-18 Thread Nicolas Frisby
The docs at http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gcd give a NB mentioning that (abs minBound == minBound) is possible for fixed-width types. This holds, for example, at Int. It is also the case that (negate minBound == minBound). Two questions: 1) This

Re: [Haskell-cafe] Template Haskell sometimes sees hidden constructors

2011-05-30 Thread Nicolas Frisby
but an alpha-equivalent type does exhibit it in my larger program. On Fri, May 27, 2011 at 12:04 PM, Nicolas Frisby nicolas.fri...@gmail.com wrote: With the three modules at the end of this email, I get some interesting results. Note that none of the constructors are exported, yet Template Haskell can

[Haskell-cafe] something between a QQ and Q Exp?

2011-05-30 Thread Nicolas Frisby
This message motivates adding support to Template Haskell for code that can be spliced but can no longer be intensionally analyzed. I'm trying to use the well-known technique of a hidden constructor in order to represent values that satisfy a particular predicate. module Safe (Safe(), safe,

[Haskell-cafe] Template Haskell sometimes sees hidden constructors

2011-05-27 Thread Nicolas Frisby
Whith the three modules at the end of this email, I get some interesting results. Note that none of the constructors are exported, yet Template Haskell can see (and splice in variable occurrences of!) T, C2, W1, and W4. If you load Dump into GHCi, you get to see the Info that TH provides when you

[Haskell-cafe] no time profiling on my MacBookPro8,1

2011-05-06 Thread Nicolas Frisby
For this vanilla program module Main where main = print $ fib 40 fib 0 = 1 fib 1 = 1 fib n = fib (n - 1) + fib (n - 2) with these commands $ ghc -prof -auto-all -rtsopts -O --make Main.hs -o Main $ ./Main +RTS -p all of the %time cells in the generated Main.prof file are 0.0, as is the

Re: [Haskell-cafe] no time profiling on my MacBookPro8,1

2011-05-06 Thread Nicolas Frisby
Whoops: I'm running Haskell Platform 2011.2.0.1. OS X 10.6.7 i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) (if that matters?) Out of my depth here. On Fri, May 6, 2011 at 5:07 PM, Nicolas Frisby nicolas.fri...@gmail.com wrote: For this vanilla program module Main where

[Haskell-cafe] what are the safety conditions for unsafeIOToST

2010-04-06 Thread Nicolas Frisby
I haven't been able to find it via Google or Haddock. An old message suggests is was just a matter of exceptions? I only want to use the IO for generating Data.Uniques to pair with STRefs in order to make a map of them. I'm guessing this would be a safe use since it's exception free (... right?).

Re: [Haskell-cafe] explicit big lambdas

2010-03-18 Thread Nicolas Frisby
Alternatively: let f :: some type involving a f = ... f' :: a - some type involving a f' _ = f in f' (undefined :: Int) normal f arguments On Thu, Mar 18, 2010 at 12:10 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: Hi Paul, You should be able to introduce \Lambda at the

[Haskell-cafe] idioms ... for using Control.Applicative.WrapMonad or Control.Arrow.Kleisli?

2010-03-01 Thread Nicolas Frisby
Each time I find myself needing to use the wrapping functions necessary for this embeddings, I grumble. Does anyone have a favorite use-pattern for ameliorating these quickly ubiquitous conversions? For runKleisli, I was considering something like okKleisli :: (Control.Arrow.Kleisli m a b -

Re: [Haskell-cafe] know a workaround for greedy context reduction?

2009-01-19 Thread Nicolas Frisby
thinking of exporting a MyLibrary.Main or MyLibrary.Instances module. Anyone have experience with this approach in a library design? Is it worth the user's extra import? Any pitfalls? On Sun, Dec 7, 2008 at 4:57 PM, Nicolas Frisby nicolas.fri...@gmail.com wrote: Seems I got ahead of myself

Re: [Haskell-cafe] Proposal for associated type synonyms in Template Haskell

2009-01-15 Thread Nicolas Frisby
Any movement on this? (I am actually just looking forward to generating kind ascriptions and having access to the kinds when processing TH.Dec, TH.Type, and such.) 2008/11/27 Simon Peyton-Jones simo...@microsoft.com: I've been away. I hope others will reply to this thread too; whatever you

Re: [Haskell-cafe] know a workaround for greedy context reduction?

2008-12-07 Thread Nicolas Frisby
a) away. So GHC must try that route. If it fails, you want it to back up to a notationally more convenient type, but GHC can't do that, I'm afraid Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:haskell-cafe- | [EMAIL PROTECTED] On Behalf Of Nicolas Frisby | Sent: 06

[Haskell-cafe] know a workaround for greedy context reduction?

2008-12-05 Thread Nicolas Frisby
With these three declarations {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} class C a where c :: a class C a = D a where d :: a instance C a = D a where d = c ghci exhibits this behavior: * :t d d :: (C a) = a Where I would prefer d :: (D a) = a. In my

[Haskell-cafe] Re: Could FDs help usurp an ATs syntactic restriction?

2008-12-05 Thread Nicolas Frisby
Perhaps this ticket is related? http://hackage.haskell.org/trac/ghc/ticket/714 On Thu, Dec 4, 2008 at 9:38 PM, Nicolas Frisby [EMAIL PROTECTED] wrote: From the error below, I'm inferring that the RHS of the associated type definition can only contain type variables from the instance head

[Haskell-cafe] two type-level programming questions

2008-12-04 Thread Nicolas Frisby
1) Type families, associated types, synonyms... can anything replace the use of TypeCast for explicit instance selection? Section 2, bullet 4 of http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap indicates a negative response. Any other ideas? 2) Any progress/options for kind polymorphism in

[Haskell-cafe] Could FDs help usurp an ATs syntactic restriction?

2008-12-04 Thread Nicolas Frisby
From the error below, I'm inferring that the RHS of the associated type definition can only contain type variables from the instance head, not the instance context. I didn't explicitly see this restriction when reading the GHC/Type_families entry. Could perhaps the a b - bn functional dependency

[Haskell-cafe] template haskell overly conservative during splicing?

2008-11-03 Thread Nicolas Frisby
When using template haskell (via Derive) to generate this (exact) instance: instance Foldable ((-) Int) = Foldable Data.Derivable.InterpreterLib.Test.List where foldMap f (Cons x0 x1) = (const mempty Cons `mappend` foldMap f x0) `mappend` foldMap f x1 foldMap f (Nil) = const

[Haskell-cafe] dangling symbolic links

2008-08-27 Thread Nicolas Frisby
I think I've exhausted my options without catching exceptions. If I have an invalid symbolic link, how can I identify that it exists? (Sorry about the line wrap.) tmp$ ls -l# no tricks up my sleeve, empty directory tmp$ touch foo tmp$ ln -s foo bar tmp$ ls -l total 8 lrwxr-xr-x 1

[Haskell-cafe] Re: dangling symbolic links

2008-08-27 Thread Nicolas Frisby
Ah the magic of using a mailing list... I just realized that using getDirectoryContents lists the entry. Still, a doesLinkExist function might be nice... On Wed, Aug 27, 2008 at 11:46 PM, Nicolas Frisby [EMAIL PROTECTED] wrote: I think I've exhausted my options without catching exceptions

[Haskell-cafe] cabal build command and package versions

2008-08-20 Thread Nicolas Frisby
I have a question about cabal's behavior for the build command. When using the build command on a cabalized project, any version changes for installed packages go unnoticed - the necessary modules in the project are not re-compiled. If however, you run the configure command (though the .cabal file

Re: [Haskell-cafe] Data Types a la Carte - automatic injections (help!)

2008-07-29 Thread Nicolas Frisby
I have accomplished this in two ways. Either drop the reflexive rule and introduce a void sentinel type or use TypeEq (... you said everything was fair game!) to explicitly specify the preference for the reflexive case over the inductive case. An advantage of TypeEq is that you can avoid

Re: [Haskell-cafe] MonadPlus

2008-05-09 Thread Nicolas Frisby
It sounds like the semantics of the MonadPlus methods are under-specified. I recall once writing a newtype wrapper to treat the same non-determinism monad with different mplus semantics, akin to cut versus backtracking. I think of MonadPlus as a less expressive version of msplit, from

Re: [Haskell-cafe] OT: Isorecursive types and type abstraction

2008-01-24 Thread Nicolas Frisby
This paper, with a pdf available at Patricia Johann's publications page http://crab.rutgers.edu/~pjohann/ seems to be related. Initial Algebra Semantics is Enough! Patricia Johann and Neil Ghani. Proceedings, Typed Lambda Calculus and Applications 2007 (TLCA'07) Hope that helps. On Jan

Re: [Haskell-cafe] Haskell purity and printing

2007-12-18 Thread Nicolas Frisby
Extensionality says that the only observable properties of functions are the outputs they give for particular inputs. Accepting extensionality as a Good Thing implies that enabling the user to define a function that can differentiate between f x = x + x and g x = 2 * x is a Bad Thing. Note that

Re: [Haskell-cafe] Haskell purity and printing

2007-12-18 Thread Nicolas Frisby
This is a fine warning you both point out, but I would suggest that it distracts from the OP's question. The previous, germane discussion holds if we assume that i) both f and g have type Integer - Integer, ii) the compiler writer is not out to get us, and iii) the GMP library, if used by that

Re: [Haskell-cafe] Re: [Haskell] Nested guards?

2007-12-04 Thread Nicolas Frisby
It seems there is previous background here that I am unaware of. I'll chime in anyway. What you describe as the wrong semantics seems to me to be the more appropriate. I am inferring that your expected behavior is explained such that the first server match ought to fail (and fall through to the

Re: [Haskell-cafe] RFC: demanding lazy instances of Data.Binary

2007-11-19 Thread Nicolas Frisby
I've got a first draft with the newtype and just an instance for list. If you'd prefer fewer questions, please let me know ;) 0) I've cabalised it (lazy-binary), but I don't have anywhere to host it. Would it be appropriate to host on darcs.haskell.org or HackageDB (yet?). Suggestions? 1)

Re: [Haskell-cafe] RFC: demanding lazy instances of Data.Binary

2007-11-19 Thread Nicolas Frisby
In light of this discussion, I think the fully spine-strict list instance does more good than bad argument is starting to sound like a premature optimization. Consequently, using a newtype to treat the necessarily lazy instances as special cases is an inappropriate bandaid. My current opinion: If

Re: [Haskell-cafe] RFC: demanding lazy instances of Data.Binary

2007-11-19 Thread Nicolas Frisby
On Nov 19, 2007 4:16 PM, Duncan Coutts [EMAIL PROTECTED] wrote: On Mon, 2007-11-19 at 13:39 -0800, Don Stewart wrote: nicolas.frisby: *snip* 1) The fact that serialisation is fully strict for 32760 bytes but not for 32761 makes the direct application of strictCheck

[Haskell-cafe] cabal Main-Is restriction

2007-11-16 Thread Nicolas Frisby
It seems the meaning of the -main-is switch for GHC and the Main-Is build option for Cabal executables differ. With GHC, I can point to any function main in any module, but in Cabal I must point to a filename with precisely the module name Main. This is tying my hands with regard to organizing a

[Haskell-cafe] RFC: demanding lazy instances of Data.Binary

2007-11-16 Thread Nicolas Frisby
I've noticed a few posts on the cafe, including my own experience, where the spine-strictness of the Binary instance for lists caused some confusion. I'd like to suggest an approach to preventing this confusion in the future, or at least making it easier to resolve. Having decided that it is

Re: [Haskell-cafe] Do you trust Wikipedia?

2007-10-17 Thread Nicolas Frisby
It is truly irresponsible to post such interesting links on a mailing list! :) I resent and thank you for the last couple hours. On 10/17/07, Dan Weston [EMAIL PROTECTED] wrote: I find the mathematics is more accurate on http://www.conservapedia.com Their facts get checked by the Almighty

Re: [Haskell-cafe] Primitive Recursive Algebraic Types

2007-08-02 Thread Nicolas Frisby
It seems you are confusing the notion of counting the number of operators in the expression with actually evaluating the expression. Your evalLength function does both. It may help to consider counting the number of operators in the expression to be the same as calculating the height of the

Re: [Haskell-cafe] Indentation woes

2007-07-26 Thread Nicolas Frisby
A bandaid suggestion: longFunctionName various and sundry arguments = f where f | guard1 = body1 f | guard2 = body2 | ... where declarations (Disclaimer: untested) As I understand it, there can be guards on the definition of f even if it takes no arguments. Those guards can reference your

Re: [Haskell-cafe] Re: advantages of using fix to define rcursive functions

2007-07-26 Thread Nicolas Frisby
in this way. On 7/26/07, Dan Piponi [EMAIL PROTECTED] wrote: On 7/26/07, Nicolas Frisby [EMAIL PROTECTED] wrote: Trying to summarize in one phrase: you can do interesting manipulations to functions before applying fix that you cannot do to functions after applying fix (conventional functions fall

Re: [Haskell-cafe] Indentation woes

2007-07-26 Thread Nicolas Frisby
Whoops, read too fast. Sorry for the noise. On 7/26/07, Stefan O'Rear [EMAIL PROTECTED] wrote: On Thu, Jul 26, 2007 at 02:58:21PM -0500, Nicolas Frisby wrote: A bandaid suggestion: longFunctionName various and sundry arguments = f where f | guard1 = body1 f | guard2 = body2

Re: [Haskell-cafe] Re: advantages of using fix to define rcursive functions

2007-07-26 Thread Nicolas Frisby
Just casting my vote for the helpfulness of this reference. Trying to summarize in one phrase: you can do interesting manipulations to functions before applying fix that you cannot do to functions after applying fix (conventional functions fall in this second category). On 7/26/07, Chung-chieh

Re: [Haskell-cafe] Maintaining the community

2007-07-13 Thread Nicolas Frisby
Perhaps an information retrieval pipedream, but what if we attempted an automated FAQ answerer? I'm sure some keywords pop-up often enough in certain chunks of first posts (heterogenous lists, existential error messages, SOE and graphics, category functor monad, etc). It could respond with the

Re: [Haskell-cafe] Maintaining the community

2007-07-13 Thread Nicolas Frisby
FYI, Gmail *can* kill threads, the Geniuses just deemed it unworthy of a UI presence. This is news to me and related to earlier comments in this thread. HTH http://mail.google.com/support/bin/answer.py?hl=enanswer=47787 On 7/13/07, Nicolas Frisby [EMAIL PROTECTED] wrote: Perhaps an information

Re: [Haskell-cafe] CPS versus Pattern Matching performance

2007-07-10 Thread Nicolas Frisby
This might be a feasible appropriation of the term destructor. On 7/10/07, Bruno Oliveira [EMAIL PROTECTED] wrote: On Tue, 10 Jul 2007 10:53:35 +0200 (MEST), Henning Thielemann wrote: On Tue, 10 Jul 2007, Tony Morris wrote: A foldr without recursion. I use such functions frequently in order to

[Haskell-cafe] advice: instantiating/duplicating modules

2007-06-29 Thread Nicolas Frisby
I wrote a combination reader/writer monad (a la the RWS monad in the mtl) and I find myself wanting to use multiple instances of it in the same stack of transformers. The functional dependencies prevent this from working out. The class is called MonadRW and the transformer is called RWT. I find

Re: [Haskell-cafe] Collections

2007-06-20 Thread Nicolas Frisby
Just a couple of examples: many non-trivial program analyses (like optimizations or type-inference) rely on viewing the AST as a graph. Graph reduction is an evaluation paradigm, and I'm guessing that a (specification-oriented) interpreter might use a graph. On 6/20/07, Andrew Coppin [EMAIL

Re: [Haskell-cafe] Collections

2007-06-19 Thread Nicolas Frisby
I don't know where you got the notion that such structures are not available in Haskell. There are many efficient data structures in the libraries. Lists are not magical, just popular, natural, and traditional. Specialized data structures are always important. Take a look at the Data.* modules

Re: [Haskell-cafe] Mysterious monads

2007-05-28 Thread Nicolas Frisby
On 5/27/07, Andrew Coppin [EMAIL PROTECTED] wrote: [snip] such that a Reader is created with an initial list, and the read function fetches 1 element out of that list. That is, the expression x - read will take the head element of the list and put it into x, keeping the tail to be read later.

Re: [Haskell-cafe] Currying: The Rationale

2007-05-23 Thread Nicolas Frisby
Disclaimer: I've not read the standard. Sections are de-sugared depending on which argument you supply: (x^) == (^) x (^x) == flip (^) x I think this is why they are considered special cases. Prelude map (^2) [1..10] [1,4,9,16,25,36,49,64,81,100] Prelude map (flip (^) 2) [1..10]

[Haskell-cafe] ambiguous type variables at MPTC

2007-05-12 Thread Nicolas Frisby
This is a question about some interesting behaviors in GHC's typechecker regarding MPTCs. The brief code is at the bottom of the message. By the way, the types can be inferred but not declared without the forall and ascription in the where clause. f1 below is illegal because we don't know what

Re: [Haskell-cafe] Obscure instances for Obscure types

2007-04-26 Thread Nicolas Frisby
I've had a similar question, which I think boiled down to a compilation issue. Consider packages A and B that can be defined independently. But, just as Neil pointed out, perhaps A and B could also interact beyond their basic definition. My naive idea is that A would compile the simple

Re: [Haskell-cafe] Tutorial on Haskell

2007-04-18 Thread Nicolas Frisby
Here here. This reminds me of a recent discussion on the cafe. Thee OP amounted to: What are the monad laws good for?. The answer was: It means the monad doesn't do surprising things and its behavior is congruent with the basic intuitions of sequenced computation. In my eyes, proving nice

Re: [Haskell-cafe] Tutorial on Haskell

2007-04-16 Thread Nicolas Frisby
One technique I find compelling is (ab)using the type class system for meta programming. Something from Lightweight Static Resources, Faking It, or Hinze's Full Circle slides might be really attractive. Perhaps Danvy's Haskell printf? The hook might be: Yeah, you've heard of strong static typing

Re: [Haskell-cafe] k-minima in Haskell

2007-04-12 Thread Nicolas Frisby
[sorry for the double, ajb] Since there seemed to be a disconnect between the expectation and the previous answers, I thought an alternative suggestion might help out. This sort of thing (haha) usually isn't my cup o' tea, so please point out any blunders. RM, is this more like what you had in

Re: [Haskell-cafe] Re: k-minima in Haskell

2007-04-12 Thread Nicolas Frisby
Both Yitzchak's and my suggestions should run in constant space--some strictness annotation or switching to foldl' might be necessary. On 4/12/07, Mark T.B. Carroll [EMAIL PROTECTED] wrote: Dan Weston [EMAIL PROTECTED] writes: Ah, but which k elements? You won't know until you've drained your

Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Nicolas Frisby
Using the Endo newtype can avoid such ambiguities: http://darcs.haskell.org/packages/base/Data/Monoid.hs newtype Endo a = Endo { appEndo :: a - a } instance Monoid (Endo a) where mempty = Endo id Endo f `mappend` Endo g = Endo (f . g) Endo allows you to explicitly select the

Re: [Haskell-cafe] Keeping a symbol table with Parsec

2007-04-02 Thread Nicolas Frisby
Section 2.12 of the Parsec manual[1] discusses user state. It sounds like that is what you are after. Hope that helps, Nick [1] - http://www.cs.uu.nl/~daan/download/parsec/parsec.pdf On 4/2/07, Joel Reymont [EMAIL PROTECTED] wrote: Folks, Are there any examples of keeping a symbol table with

Re: [Haskell-cafe] A wish for relaxed layout syntax

2007-03-28 Thread Nicolas Frisby
I don't think that aName = [ x , y , z ] can be beat for adaptability (i.e. adding/removing/reorganizing results or _especially_ renaming the declaration). Doesn't do so hot regarding vertical space though... On 3/28/07, Greg Buchholz [EMAIL PROTECTED] wrote: David House wrote: I see

Re: [Haskell-cafe] Re: A question about functional dependencies and existential

2007-03-28 Thread Nicolas Frisby
A wee bit off topic... but bear with me. Oleg points out a distinction between declaring a class with functional dependencies and implementing a class with functional dependencies. Judging from my experience, it might behoove those wrestling with type classes and FDs to emphasize that the class

Re: [Haskell-cafe] Re: Why the Prelude must die

2007-03-27 Thread Nicolas Frisby
Gut feeling: the quick'n dirty script case occurs far less than the whole module case. Thus I think the benefit of automatically importing the Prelude if the module declaration is omitted should not happen: the Principle of Least Surprise out-weighs the small benefit to a rare case. Correct me

[Haskell-cafe] ghc warning Var/Type length mismatch

2007-03-22 Thread Nicolas Frisby
When I load my program, GHC spits these messages at me, but doesn't fail Any idea what might be causing this or how to figure that out? Var/Type length mismatch: [] [a{tv aGIf} [tau]] ... Var/Type length mismatch: [] [a{tv aGN8} [tv]] ... I found the responsible code in GHC's darcs,

Re: [Haskell-cafe] There can be only one fix? Pondering Bekic's lemma

2007-03-21 Thread Nicolas Frisby
Whooops. Thanks for the correction. On 3/20/07, Levent Erkok [EMAIL PROTECTED] wrote: On 3/19/07, Nicolas Frisby [EMAIL PROTECTED] wrote: Nope, but I believe the two are equipotent. This usage of believe is one of those I think I remember reading it somewhere usages. On 3/19/07, Henning

Re: [Haskell-cafe] Re: fix

2007-03-20 Thread Nicolas Frisby
In effect, this is a demonstration that Haskell supports recursive values and not just recursive functions. If the a in fix :: (a - a) - a were to be unified always with a function type, then that would imply that the language only supported recursive definitions for functions, which would be a

Re: [Haskell-cafe] There can be only one fix? Pondering Bekic's lemma

2007-03-19 Thread Nicolas Frisby
Nope, but I believe the two are equipotent. This usage of believe is one of those I think I remember reading it somewhere usages. On 3/19/07, Henning Thielemann [EMAIL PROTECTED] wrote: On Sat, 17 Mar 2007, Nicolas Frisby wrote: Bekic's lemma [1], allows us to transform nested fixed points

[Haskell-cafe] There can be only one fix? Pondering Bekic's lemma

2007-03-17 Thread Nicolas Frisby
Bekic's lemma [1], allows us to transform nested fixed points into a single fixed point, such as: fix (\x - fix (\y - f (x, y))) = fix f where f :: (a, a) - a This depends on having true products, though I'm not exactly sure what that means. Mutual recursion can also be described with

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Nicolas Frisby
That said, N and R are indeed categories; however, considering them as categories should be carefully interlaced with your intuitions about them as types. I haven't formally checked it, but I would bet that this endofunctor over N, called Sign, is a monad: Sign x = x + x Pos = injectLeft Neg

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Nicolas Frisby
Thanks for keeping me honest ;) On 3/15/07, Dominic Steinitz [EMAIL PROTECTED] wrote: I haven't formally checked it, but I would bet that this endofunctor over N, called Sign, is a monad: Just to be picky a functor isn't a monad. A monad is a triple consisting of a functor and 2 natural

Re: [Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Nicolas Frisby
It seems like we could refine the first parameter of carryPropagate just as the second: make an= type N1 that only admits values [1..]. Would not that suffice to prove that base is never 0 and not have to go beyond the type-checker for a proof? On 3/13/07, Neil Mitchell [EMAIL PROTECTED] wrote:

Re: [Haskell-cafe] Usage of . and $

2007-03-07 Thread Nicolas Frisby
Which is the longer way of saying you don't need to count to make sure you closed all the brackets you opened! ;-) Dougal Stanton 1) Emacs does the counting for me 2) parens don't surprise me if I happen to use rank-2 types. i was bit enough times when learning why $ and runST don't like

Re: [Haskell-cafe] Usage of . and $

2007-03-07 Thread Nicolas Frisby
I don't use rank-2 types that often and when I do I'm aware of the restriction on ($) and similar hofs. I tend to use ($) only when the right-hand side gets very messy; a multiple-line do or similar. For example: blah = fromMaybe $ do x - blah1 y - blah2 guard (x == f y) g x The closing

Re: [Haskell-cafe] Usage of . and $

2007-03-06 Thread Nicolas Frisby
sum . IntMap.elems . IntMap.IntersectionWith (\x y - x*y) queryVector rationalProjection Composition with (.) builds a function, but you eventually want an Int, so we can't just use (.), but we can come pretty close. (sum . IntMap.elems . IntMap.IntersectionWith (\x y - x*y) queryVector)

Re: [Haskell-cafe] Takusen and strictness

2007-03-02 Thread Nicolas Frisby
The deep, dark, Aslan magic of getContents is usually safe to use because it's a read-only operation. Some of the dangerous corners of getContents are: what happens if the file is altered while we read it lazily? This is the sort of question that the sequencing notion of the IO monad is supposed

Re: [Haskell-cafe] Automatic Recognition of Functors

2007-03-01 Thread Nicolas Frisby
This link might be what you are after: http://okmij.org/ftp/Haskell/typecast.html#deepest-functor On 3/1/07, Walter Potter [EMAIL PROTECTED] wrote: Folks, Given f:: a - b it is very natural to lift f to P f :: P a - P b where P is the power set functor. Or L f :: [a] - [b]. We are modeling

Re: [Haskell-cafe] What inhabits this type: (forall a. a - b) - (forall a. m a - m b)

2007-02-27 Thread Nicolas Frisby
The type doesn't actually indicate that the type m supports a return operation. I introduced the qualifier that it was a functor. You implicity introduced the constraint that it is a monad (actually a pointed functor, but that's a Monad's return operator). With that constraint, your thought

Re: [Haskell-cafe] exists . a psuedo-standard non-empty list module

2007-02-21 Thread Nicolas Frisby
Despite the fact that I like head/fromJust etc, a safe list library would be kind of handy. If someone wants to roll that into the Safe library, as Safe.List or something, I'd be happy to accept patches (saving someone else the hassle of setting up a new library etc, for roughly the same purpose)

Re: [Haskell-cafe] newbie question about denotational semantics

2007-02-20 Thread Nicolas Frisby
I'm still getting my head around this myself, but I know a few references that might help (maybe not directly, but they're in the ballpark). 1 I believe the phrase natural lifting or naturality of liftings is what you're after when you attempt to compare a monad and a bigger monad that includes

Re: [Haskell-cafe] newbie question about denotational semantics

2007-02-20 Thread Nicolas Frisby
[my mail program hiccuped and chopped my message, sorry] 2 Another example that helped me when getting a feel for reasoning about monadic code (which is the basis of what we're doing here) was William Harrison's Proof Abstraction for Imperative Languages. It uses monads and some of the notions

Re: [Haskell-cafe] Re: Map list of functions over a single argument

2007-02-20 Thread Nicolas Frisby
Here comes an overwhelming post (so stop here if you're not interested in applicative functors), but apfelmus stepped in this direction. The funny part is that, modulo dictionary passing (which might be compiled away), all 6 functions below do the Exact Same Thing because of newtype erasure

Re: [Haskell-cafe] Re: Genuine Eratosthenes sieve [Was: Optimization fun]

2007-02-19 Thread Nicolas Frisby
to express very complicated algorithms in simple and elegant ways, you have to expect to pay a constant factor (roughly 2x-10x) when competing against the same algorithm in low-level C. and this one from Nicolas Frisby, I have yet to need my Haskell to perform well Matthew Brecknell came up

[Haskell-cafe] our worst unsafePerformIO nightmares are upon us!

2007-02-17 Thread Nicolas Frisby
http://www.thinkgeek.com/geektoys/cubegoodies/86b8/ Now you can really show your coders why unsafePerformIO is to be avoided! -Nick ps - Please don't consider this post a product advertisement or endorsement of any kind. ___ Haskell-Cafe mailing list

[Haskell-cafe] exists . a psuedo-standard non-empty list module

2007-02-15 Thread Nicolas Frisby
I don't particularly like using fromJust or head, and there's been plenty of discussion on those issues. For the cases where it makes good sense to do so, I'm about to write a module for non-empty lists that looks to strike a balance between usability and static checks. But before I re-invent the

Re: [Haskell-cafe] SoC: Port Haddock to use GHC

2007-02-15 Thread Nicolas Frisby
. 18.19 skrev Nicolas Frisby: I am very ready for a Haddock that can swallow infix typenames. Yes, Haddock-GHC can do that. In dons's recent overview of the last SoC, a darcs repo for Waern's project was listed. I jumped at the link but couldn't find much documentation (i.e. the README file

Re: [Haskell-cafe] Foldr tutorial, Inspired by Getting a Fix from a Fold

2007-02-12 Thread Nicolas Frisby
Guess this is a tricky choice for a foldr intro, since it requires a paramorphism (see bananas lenses wires etc.) para :: (a - [a] - b - b) - b - [a] - b para f e [] = e para f e (x:xs) = f x xs (para f e xs) -- note that the original tail of the list (i.e. xs and not xs') is used in the

Re: [Haskell-cafe] Foldr tutorial, Inspired by Getting a Fix from a Fold

2007-02-12 Thread Nicolas Frisby
Oops; I totally forgot the context of this whole discussion! I enjoyed your article. On 2/12/07, Bernie Pope [EMAIL PROTECTED] wrote: Nicolas Frisby wrote: Guess this is a tricky choice for a foldr intro, since it requires a paramorphism (see bananas lenses wires etc.) para :: (a - [a] - b

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Nicolas Frisby
Very rarely is a nontrivial solution the only way. Monads are a construct that nicely represents the sequencing side-effecting computations in a pure and strongly-typed environment. They are a nice way to do it, but certainly not the only one. Now I'm not confident enough to boldly make this

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Nicolas Frisby
A wee bit off topic, but I'm sure it's an acceptable detour. I just wanted to say that I appreciate both this sort of post and the consistent responses it solicits. I have yet to need my Haskell to perform well, but I'm sure that day will come. I like to follow these questions and hopefully be

[Haskell-cafe] mtl tweaks

2007-01-21 Thread Nicolas Frisby
There have been some discussions of augmentations of the monad transformer library. I at least know there was a discussion regarding strictness of state/value components in the state monad transformer (I must admit I didn't track the conclusion of that one). I have another small mtl complaint:

Re: [Haskell-cafe] State separation/combination pattern question

2006-12-23 Thread Nicolas Frisby
Another option is to use the HList library (though this can involve a learning curve). Essentially your monad is a state monad and its state is a big tuple constrained to contain at least whichever types you ask of it. Consider foo :: (HOccurs StateA st, ...other HList properties..., MonadState

Re: Re: [Haskell-cafe] AT solution: rebinding = for restricted monads

2006-12-19 Thread Nicolas Frisby
On the FD impasse: Witness.hs:33:0: Couldn't match expected type `m'' (a rigid variable) against inferred type `RealWitness a a'' `m'' is bound by the type signature for `' at Witness.hs:11:29 When using functional dependencies to combine Witness WitnessReally a

Re: [Haskell-cafe] type hackery question

2006-12-17 Thread Nicolas Frisby
[Sorry for the duplicate Jeff.] Is it possible to write a class which checks to see if two given type arguments are unifiable? This will probably help: http://www.haskell.org/pipermail/haskell-cafe/2006-November/019705.html That was Oleg's response to a post of mine:

Re: Re: [Haskell-cafe] Composing monads (sort of)

2006-12-16 Thread Nicolas Frisby
Once I start needing to combine Maybe with other monads, I usually take a moment to generalize the appropriate Maybe parts to MonadError e m = m. Then we can just use the (ErrorT e IO) monad. Nick On 12/16/06, Pepe Iborra [EMAIL PROTECTED] wrote: Wait, there are two monads in scene here, IO

Re: Re: [Haskell-cafe] Building the community

2006-12-14 Thread Nicolas Frisby
On 12/14/06, Ross Paterson [EMAIL PROTECTED] wrote: Absolutely. Some more questions of this type: How do I update a variable? How can I efficiently update an array? How do I get debugging output? How can I put different types of things in a list? Sometimes the

[Haskell-cafe] less than helpful GHC error message

2006-12-13 Thread Nicolas Frisby
Consider the terminal session at the bottom of this message. The extra xc in Test.hs was the result of me missing CTRL during an Emacs command (I'm guessing...). Unfortunately this took 30 minutes to find since I had far more than two modules and the error message doesn't point this out. Sure

[Haskell-cafe] type variable question

2006-12-13 Thread Nicolas Frisby
I'm developing a typesafe record library (akin to HList but starting with key/val pairs and enforcing uniqueness and sorted order of keys). I'm having a GHC problem I've had with other projects and seen comments regarding it in other people's code (HList for instance: GHC doesn't like it's own

Re: [Haskell-cafe] Stratified monads

2006-12-11 Thread Nicolas Frisby
As far as I know, the stratified monads are recognized as monad transformers in Haskell. The predominant library is the Monad Transformer Library (or mtl) coded by Andy Gill, see [1]. One of my favorite examples of the usefulness of monad transformers is for building domains for denotational

Re: Re: Re: [Haskell-cafe] Writing Haskell For Dummies Or At Least For People Who Feel Like Dummies When They See The Word 'Monad'

2006-12-11 Thread Nicolas Frisby
I have taken the liberty to read into the definition of practical Haskell; if I'm off target let me know so I can tweak my claims to fit whatever it is I thought I was discussing ;). Two cents: 1) This wouldn't be the first book introducing functional programming to imperative programmers. It

Re: Re: [Haskell-cafe] Cannot understand liftM2

2006-12-11 Thread Nicolas Frisby
The interpreter infers that m = (e -) because of the types of snd and fst. When snd and fst are considered as monadic computations in the (e -) monad, there types are: Prelude :t fst fst :: (a, b) - a Prelude :t snd snd :: (a, b) - b Note that: (a, b) - a =~= m awhere m x = (a,b) - x So

Re: Re: [Haskell-cafe] interval arithmetic for integers?

2006-12-08 Thread Nicolas Frisby
the kind I'm thinking of. That package has what seems like scary math. Thanks, Nick On 12/8/06, Taral [EMAIL PROTECTED] wrote: Some of that is in the Ranged Sets library: http://ranged-sets.sourceforge.net/Ranged/ but it doesn't support Num. On 12/8/06, Nicolas Frisby [EMAIL PROTECTED] wrote: I'm

Re: Re: Re: [Haskell-cafe] interval arithmetic for integers?

2006-12-08 Thread Nicolas Frisby
Fantastic! Just another bit of evidence that Haskell Cafe + one night's sleep can save a great deal of work. :) Thanks for pointing that out, Nick On 12/8/06, Taral [EMAIL PROTECTED] wrote: On 12/8/06, Nicolas Frisby [EMAIL PROTECTED] wrote: I did see that one on the wiki; but it doesn't

[Haskell-cafe] interval arithmetic for integers?

2006-12-07 Thread Nicolas Frisby
I'm looking to not reinvent the wheel. Is there an existing package that supports interval arithmetic on integers (or more)? A possible complication is that I'm hoping to include open intervals such as (GreaterEqThan 3). If there's not a package to go with, any pointers on the appopriate rules

Re: [Haskell-cafe] (a - [b]) - [a - b] ?

2006-12-04 Thread Nicolas Frisby
It seems there's an assumption about the range of the parameter function and the range of the entire function. That is, I think we're assuming that the length of the final result is the same as the length of the result of the first function? If I'm correct in presuming that constraint, then I

Re: Re: [Haskell-cafe] Parsec: Where's +++?

2006-12-01 Thread Nicolas Frisby
A agreed upon technique for dealing with typeclass hierarchies has been slow to arrive. For instance, all monads are functors, but providing a monad instance for your type doesn't automatically make it a functor as well. All monads are also applicative functors, and Control.Applicative does have

[Haskell-cafe] haddock infix questions

2006-11-28 Thread Nicolas Frisby
I found nothing in the Gmane archives, so I turn to you. I'm hoping to Haddock-a-chop my library but the ole infix type constructor (and there are many of them) is causing a parse error. It seems a common enough problem, so I was wondering... 1) What ended up happening with David Waern's SoC

Re: Re: [Haskell-cafe] Collection of objects?

2006-11-17 Thread Nicolas Frisby
Depending on your needs and your comfort level with fancier types, the existential approach to ADTs might solve your problem. The following code is a demonstration you can cut-and-paste-and-run. This is example akin to upcasting in Java to an interface that lets you print things. That way you

  1   2   >