Re: [Haskell-cafe] Grok Monad Transformers - some help needed

2012-01-02 Thread Steve Horne

On 02/01/2012 06:12, Arseniy Alekseyev wrote:

  I don't know what to actually do with this after putting it in a *.lhs file.

You can :load *.lhs into ghci the same way you load .hs-files.

I swear I tried this before, but now it suddenly works.

Must be the chaos of stupid random assumptions making me do stupid 
things - I go through this phase with anything new. I have no idea what 
I was doing to screw things up, but I'm pretty there's no conspiracy to 
drive me nuts. Though now I think of it... hmmm... I wonder...


The errors I was getting from GHC mostly referred to the monomorphism 
restriction - at least for test1 and test2. The errors for test3 were 
much longer and scarier.


I'll try to figure out what's different going from GHC to GHCi later - 
for the moment, I'm getting back to those transformers.


BTW - interesting how the signatures of test1 and test2 are reported - I 
hadn't realised monad transformers were relevant there. Of course it 
does seem a bit silly to implement both StateT and State when StateT can 
implement State for you.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How to split this string.

2012-01-02 Thread max
I want to write a function whose behavior is as follows:

foo string1\nstring2\r\nstring3\nstring4 = [string1,
string2\r\nstring3, string4]

Note the sequence \r\n, which is ignored. How can I do this?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Yves Parès
Doesn't the function lines handle different line-endings?
(In the Prelude and in Data.List)

If not, doing this with parsec would be easy (yet maybe slightly
overkill...)


2012/1/2 max m...@mtw.ru

 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

 ___
 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 split this string.

2012-01-02 Thread max
В Mon, 2 Jan 2012 10:45:18 +0100
Yves Parès limestr...@gmail.com пишет:

Prelude lines string1\nstring2\r\nstring3\nstring4
[string1,string2\r,string3,string4]

 Doesn't the function lines handle different line-endings?
 (In the Prelude and in Data.List)
 
 If not, doing this with parsec would be easy (yet maybe slightly
 overkill...)
 
 
 2012/1/2 max m...@mtw.ru
 
  I want to write a function whose behavior is as follows:
 
  foo string1\nstring2\r\nstring3\nstring4 = [string1,
  string2\r\nstring3, string4]
 
  Note the sequence \r\n, which is ignored. How can I do this?
 
  ___
  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 split this string.

2012-01-02 Thread Simon Hengel
 Doesn't the function lines handle different line-endings?
 (In the Prelude and in Data.List)
It does not ignore \r\n.

Cheers,
Simon

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] On the purity of Haskell

2012-01-02 Thread Jerzy Karczmarczuk

Conal Elliott cites Steve Horne:


I look at this World parameter as purely hypothetical, a trick
used to gain an intuition. Whereas Jerzy (I think) uses it to
claim Haskell is referentially transparent - those differing x and
y values come from different worlds, or different world-states.


I don't see this interpretation in Jerzy's words, and I'd be very 
surprised if he had that sort of argument in mind.
I don't think either having used the 'World' model as an argument of the 
referential transparency.
The main reason is that I don't know what does it mean, the referential 
transparency of the real world.


There is a philosophical issue involved: the problem of IDENTITY, which 
is as old as the humanity, and it will survive it... We simply don't 
know what does it mean: the same...


But I disagree quite strongly with the idea of /World parameter as 
purely hypothetical, a trick used to gain an intuition/. I mentioned 
the language Clean (no reaction, seems that Haskellians continue to 
ignore it...)


In Clean this IS the IO model. You have such entities as FileSystem, 
which has the Unique Access property, etc. You can put all that in an 
equivalent of the IO Monad, constructed within Clean itself, not as a 
primitive.


Jerzy

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Dutch FP day 2012, January 6; ; reminder, and happy new year to all of you

2012-01-02 Thread S D Swierstra
We are happy to announce that the next Dutch functional programming day will 
take place on January 6, 2012, at the university campus de Uithof of Utrecht 
University.

The program, participants registered thus far, and further details can be found 
at: http://www.cs.uu.nl/wiki/bin/view/FPDag2012/WebHome 

If you are aware of people who might not be on the mailing list and might be 
interested (e.g. your students), please point this information out to them.


Please do not forget to tell me that you whether you want to go to the dinner 
too.

Best, hoping to see you all,
Doaitse





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Christian Maeder

Am 02.01.2012 10:44, schrieb max:

I want to write a function whose behavior is as follows:

foo string1\nstring2\r\nstring3\nstring4 = [string1,
string2\r\nstring3, string4]

Note the sequence \r\n, which is ignored. How can I do this?


replace the sequence by something unique first, i.e. a single \r (and 
revert this change later).


(Replacing a single character is easier using concatMap).

HTH Christian

-- | replace first (non-empty) sublist with second one in third
-- argument list
replace :: Eq a = [a] - [a] - [a] - [a]
replace sl r = case sl of
  [] - error replace: empty list
  _ - concat . unfoldr (\ l - case l of
[] - Nothing
hd : tl - Just $ case stripPrefix sl l of
  Nothing - ([hd], tl)
  Just rt - (r, rt))


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] On the purity of Haskell

2012-01-02 Thread David Sabel

A perhaps acceptable notion of the property we want (purity etc.) is
that all the extensions of the purely functional core language of Haskell
(say the lazy lambda calculus extended with data constructors, etc) are
_conservative_, that is all the equations that hold
in the pure core language still hold in the extended language.

For a part of Concurrent Haskell such a conservativity result is shown in
 D.Sabel , M. Schmidt-Schauß. On conservativity of Concurrent Haskell. 
Frank report 47, 2011.

http://www.ki.informatik.uni-frankfurt.de/papers/frank/frank-47.pdf
It also shows that with arbitrary use of unsafeInterleaveIO 
conservativity does not hold.


And of course the result does not capture any IO-operation (only 
takeMVar, putMVar and spawning threads are considered),

but it may be extended to more operations ...

Just my two cents,
 David

On 30.12.2011 02:07, Conal Elliott wrote:
I wrote that post to point out the fuzziness that fuels many 
discussion threads like this one. See also 
http://conal.net/blog/posts/notions-of-purity-in-haskell/ and the 
comments.


I almost never find value in discussion about whether language X is 
functional, pure, or even referentially transparent, mainly 
because those terms are used so imprecisely. In the notions-of-purity 
post, I suggest another framing, as whether or not a language and/or 
collection of data types is/are denotative, to use Peter Landin's 
recommended replacement for functional, declarative, etc. I 
included some quotes and a link in that post. so people can track down 
what denotative means. In my understanding, Haskell-with-IO is not 
denotative, simply because we do not have a (precise/mathematical) 
model for IO. And this lack is by design, as explained in the toxic 
avenger remarks in a comment on that post.


I often hear explanations of what IO means (world-passing etc), but I 
don't hear any consistent with Haskell's actual IO, which includes 
nondeterministic concurrency. Perhaps the difficulties could be 
addressed, but I doubt it, and I haven't seen claims pursued far 
enough to find out.


  - Conal

On Thu, Dec 29, 2011 at 4:42 PM, Steve Horne 
sh006d3...@blueyonder.co.uk mailto:sh006d3...@blueyonder.co.uk wrote:


On 30/12/2011 00:16, Sebastien Zany wrote:

Steve Horne wrote:

I haven't seen this view explicitly articulated anywhere before


See Conal Elliott's blog post The C language is purely functional
http://conal.net/blog/posts/the-c-language-is-purely-functional.

Thanks - yes, that's basically the same point. More concise - so
clearer, but not going into all the same issues - but still the
same theme.

___

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Steve Horne

On 02/01/2012 09:44, max wrote:

I want to write a function whose behavior is as follows:

foo string1\nstring2\r\nstring3\nstring4 = [string1,
string2\r\nstring3, string4]

Note the sequence \r\n, which is ignored. How can I do this?
Doing it probably the hard way (and getting it wrong) looks like the 
following...


--  Function to accept (normally) a single character. Special-cases
--  \r\n. Refuses to accept \n. Result is either an empty list, or
--  an (accepted, remaining) pair.
parseTok :: String - [(String, String)]

parseTok  = []
parseTok (c1:c2:cs) | ((c1 == '\r')  (c2 == '\n')) = [(c1:c2:[], cs)]
parseTok (c:cs) | (c /= '\n')= [(c:[], cs)]
| True   = []

--  Accept a sequence of those (mostly single) characters
parseItem :: String - [(String, String)]

parseItem  = [(,)]
parseItem cs = [(j1s ++ j2s, k2s)
 | (j1s,k1s) - parseTok  cs
 , (j2s,k2s) - parseItem k1s
   ]

--  Accept a whole list of strings
parseAll :: String - [([String], String)]

parseAll [] = [([],)]
parseAll cs = [(j1s:j2s,k2s)
| (j1s,k1s) - parseItem cs
, (j2s,k2s) - parseAll  k1s
  ]

--  Get the first valid result, which should have consumed the
--  whole string but this isn't checked. No check for existence either.
parse :: String - [String]
parse cs = fst (head (parseAll cs))

I got it wrong in that this never consumes the \n between items, so 
it'll all go horribly wrong. There's a good chance there's a typo or two 
as well. The basic idea should be clear, though - maybe I should fix it 
but I've got some other things to do at the moment. Think of the \n as a 
separator, or as a prefix to every item but the first. Alternatively, 
treat it as a prefix to *every* item, and artificially add an initial 
one to the string in the top-level parse function. The use tail etc to 
remove that from the first item.


See http://channel9.msdn.com/Tags/haskell - there's a series of 13 
videos by Dr. Erik Meijer. The eighth in the series covers this basic 
technique - it calls them monadic and uses the do notation and that 
confused me slightly at first, it's the *list* type which is monadic in 
this case and (as you can see) I prefer to use list comprehensions 
rather than do notation.


There may be a simpler way, though - there's still a fair bit of Haskell 
and its ecosystem I need to figure out. There's a tool called alex, for 
instance, but I've not used it.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Anupam Jain
On Mon, Jan 2, 2012 at 3:14 PM, max m...@mtw.ru wrote:
 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

Here's a simple way (may not be the most efficient) -

import Data.List (isSuffixOf)

split = reverse . foldl f [] . lines
  where
f [] w = [w]
f (x:xs) w = if \r `isSuffixOf` x then ((x++\n++w):xs) else (w:x:xs)

Testing -

ghci split ab\r\ncd\nefgh\nhijk
[ab\r\ncd,efgh,hijk]


-- Anupam

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread emacsray
On Mon, Jan 02, 2012 at 12:44:23PM +0300, max wrote:
 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

unixLines :: String - [String]
unixLines xs = reverse . map reverse $ go xs  []
  where
go [] l ls = l:ls
go ('\r':'\n':xs) l ls = go xs ('\n':'\r':l) ls
go ('\n':xs) l ls = go xs  (l:ls)
go (x:xs) l ls = go xs (x:l) ls

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] On the purity of Haskell

2012-01-02 Thread Steve Horne

On 02/01/2012 10:03, Jerzy Karczmarczuk wrote:
But I disagree quite strongly with the idea of /World parameter as 
purely hypothetical, a trick used to gain an intuition/. I mentioned 
the language Clean (no reaction, seems that Haskellians continue to 
ignore it...)



I don't know about others, but I intend to learn one language at a time.

In any case, that's Clean, not Haskell.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Yves Parès
Okay, so it doesn't handle different line-endings.

I have a more general solution (statefulSplit)
http://hpaste.org/55980

I cannot test it as I don't have an interpreter at hand, but if someone
has, I'd be glad to have comments.
(It might be more readable by using the State monad)

2012/1/2 max m...@mtw.ru

 В Mon, 2 Jan 2012 10:45:18 +0100
 Yves Parès limestr...@gmail.com пишет:

 Prelude lines string1\nstring2\r\nstring3\nstring4
 [string1,string2\r,string3,string4]

  Doesn't the function lines handle different line-endings?
  (In the Prelude and in Data.List)
 
  If not, doing this with parsec would be easy (yet maybe slightly
  overkill...)
 
 
  2012/1/2 max m...@mtw.ru
 
   I want to write a function whose behavior is as follows:
  
   foo string1\nstring2\r\nstring3\nstring4 = [string1,
   string2\r\nstring3, string4]
  
   Note the sequence \r\n, which is ignored. How can I do this?
  
   ___
   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 split this string.

2012-01-02 Thread Jon Fairbairn
max m...@mtw.ru writes:

 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

cabal install split

then do something like

   import Data.List (groupBy)
   import Data.List.Split (splitOn)

   rn '\r' '\n' = True
   rn _ _ = False

   required_function = fmap concat . splitOn [\n] . groupBy rn

(though that might be an abuse of groupBy)

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread emacsray
On Mon, Jan 02, 2012 at 12:44:23PM +0300, max wrote:
 I want to write a function whose behavior is as follows:

 foo string1\nstring2\r\nstring3\nstring4 = [string1,
 string2\r\nstring3, string4]

 Note the sequence \r\n, which is ignored. How can I do this?

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

A short yet requiring regex solution:

   import Text.Regex.PCRE
   match (makeRegex (?:[^\r\n]+|\r\n)+ :: Regex) b\nc\r\n\n\r\n\nd :: 
[[String]]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Grok Monad Transformers - some help needed

2012-01-02 Thread Brandon Allbery
On Mon, Jan 2, 2012 at 03:32, Steve Horne sh006d3...@blueyonder.co.ukwrote:

 BTW - interesting how the signatures of test1 and test2 are reported - I
 hadn't realised monad transformers were relevant there. Of course it does
 seem a bit silly to implement both StateT and State when StateT can
 implement State for you.


If you're using the mtl1 library, State is separate from StateT.  With the
transformers library (or mtl2, which is a wrapper for transformers) State
is defined as StateT Identity.  Part of the reason for this is that older
ghc didn't optimize very well with something like StateT Identity; part is
simply because monad transformers came later and nobody bothered to go back
and rework the standalone monads as transformers over an Identity monad.
 The original Monad library included non-transformer-based multi-monads
such as RWS (Reader+Writer+State) as well, since nobody has worked out
transformers as a concept yet.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread max
В Mon, 02 Jan 2012 11:12:49 +
Jon Fairbairn jon.fairba...@cl.cam.ac.uk пишет:

 max m...@mtw.ru writes:
 
  I want to write a function whose behavior is as follows:
 
  foo string1\nstring2\r\nstring3\nstring4 = [string1,
  string2\r\nstring3, string4]
 
  Note the sequence \r\n, which is ignored. How can I do this?
 
 cabal install split
 
 then do something like
 
import Data.List (groupBy)
import Data.List.Split (splitOn)
 
rn '\r' '\n' = True
rn _ _ = False
 
required_function = fmap concat . splitOn [\n] . groupBy rn
 
 (though that might be an abuse of groupBy)
 

This is the simplest solution of the proposed, in my opinion. Thank you
very much.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Felipe Almeida Lessa
On Mon, Jan 2, 2012 at 10:12 AM, max m...@mtw.ru wrote:
 This is the simplest solution of the proposed, in my opinion. Thank you
 very much.

Better yet, don't use String and use Text.  Then you just need
T.splitOn \r\n [1].

Cheers,

[1] 
http://hackage.haskell.org/packages/archive/text/0.11.1.12/doc/html/Data-Text.html#v:splitOn

-- 
Felipe.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Anupam Jain
On Mon, Jan 2, 2012 at 5:52 PM, Felipe Almeida Lessa
felipe.le...@gmail.com wrote:
 On Mon, Jan 2, 2012 at 10:12 AM, max m...@mtw.ru wrote:
 This is the simplest solution of the proposed, in my opinion. Thank you
 very much.

 Better yet, don't use String and use Text.  Then you just need
 T.splitOn \r\n [1].

That is actually the opposite of what the OP wants, however it's
interesting that Text has a function like that and not the String
functions in the standard
library.

-- Anupam

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] space-efficient, composable list transformers [was: Re: Reifying case expressions]

2012-01-02 Thread Heinrich Apfelmus

Sebastian Fischer wrote:

Your `ListTo` type achieves space efficiency for Applicative composition of
list functions by executing them in lock-step. Because of the additional
laziness provided by the `Fmap` constructor, compositions like

interpret a . interpret b

can also be executed in constant space. However, we cannot use the space
efficient Applicative combinators again to form parallel compositions of
sequential ones because we are already in the meaning type.

We could implement composition for the `ListTo` type as follows

(.) :: ListTo b c - ListTo a [b] - ListTo a c
a . b = interpret a $ b

But if we use a result of this function as argument of *, then the
advantage of using `ListTo` is lost. While

interpret ((,) $ andL * andL)

runs in constant space,

interpret ((,) $ (andL . idL) * (andL . idL))

does not.

The ListTransformer type supports composition in lock-step via a category
instance. The meaning of `ListTransformer a b` is `[a] - [b]` with the
additional restriction that all functions `f` in the image of the
interpretation function are incremental:

xs `isPrefixOf` ys  ==  f xs `isPrefixOf` f ys

[..]

The Applicative instance for `ListTransformer` is different from the
Applicative instance for `ListTo` (or `ListConsumer`). While

interpret ((,) $ idL * idL)

is of type `[a] - ([a],[a])`

transformList ((,) $ idL * idL)

is of type `[a] - [(a,a)]`. 
[..]


Ah, so  ListTransformer  is actually quite different from  ListTo 
because the applicative instance yields a different type. Then again, 
the former can be obtained form the latter via  unzip .



I have a gut feeling that the laziness provided by the `Fmap` constructor
is too implicit to be useful for the kind of lock-step composition provided
by ListTransformer. So I don't have high hopes that we can unify
`ListConsumer` and `ListTransformer` into a single type.

Do you have an idea?


Well, the simple solution would be to restrict the type of  (.)  to

(.) :: ListTo b c - ListTransformer a b - ListTo a c

so that the second argument is guaranteed to be incremental. Of course, 
this is rather unsatisfactory.


Fortunately, there is a nicer solution that keeps everything in the 
ListTo  type. The main problem with  Fmap  is that it can be far from 
incremental, because we can plug in any function we like:


example :: ListTo a [a]
example = Fmap reverse

Without an explicit guarantee that the function is incremental, we can't 
do anything here. But we can just add another constructor to that effect 
if we turn  ListTo  into a GADT:


data ListTo a b where
CaseOf   :: b -  (a - ListTo a b)  - ListTo a b
Fmap :: (b - c) - ListTo a b   - ListTo a c

FmapCons :: b - ListTo a [b] - ListTo a [b]

The interpretation for this case is given by the morphism

interpret (FmapCons x g) = fmap (x:) $ interpret g

and sequential composition reads

-- sequential composition
-- interpret (a . b) = interpret $ interpret a $ b
(.) :: ListTo b c - ListTo a [b] - ListTo a c
(CaseOf _ cons) . (FmapCons y b) = cons y . b
(Fmap f a)  . (FmapCons y b) = Fmap f $ a . (FmapCons y b)
(FmapCons x a)  . (FmapCons y b) = FmapCons x $ a . (FmapCons y b)
a . (CaseOf nil cons) = CaseOf (interpret a nil) ((a .) . cons)
a . (Fmap f b)= fmap (interpret a . f) b

Of course, the identity has to be redefined to make use of the new guarantee

idL :: ListTo a [a]
idL = caseOf [] $ \x - FmapCons x idL

I'm going to omit the new definition for the applicative instance, the 
full code can be found here:


https://gist.github.com/1550676

With all these combinators in place, even examples like

liftA2 (,) (andL . takeL 3) (andL . idL)

should work as expected.


While nice, the above solution is not perfect. One thing we can do with 
 ListTransformer  type is to perform an apply first and then do a 
sequential composition.


a . (b * c)

This only works because the result of  *  is already zipped.


And there is an even more worrisome observation: all this work would 
have been superfluous if we had *partial evaluation*, i.e. if it were 
possible to evaluate expressions like  \xs - f (4:xs)  beneath the 
lambda. Then we could dispense with all the constructor yoga above and 
simply use a plain


 type ListTo a b = [a] - b

with the applicative instance

 instance Applicative (ListTo a) where
 pure b = const b
 (f * x) cs = case cs of
 [] - f [] $ x []
 (c:cs) - let f' = f . (c:); x; = x . (c:) in
   f' `partialseq` x' `partialseq` (f' * x')

to obtain space efficient parallel and sequential composition. In fact, 
by using constructors, we are essentially doing partial evaluation by hand.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org

[Haskell-cafe] Experiments in Haskell Packaging

2012-01-02 Thread Chris Dornan
Hi All,

The http://justhub.org Haskell distribution for Enterprize Linux
(RHEL/CentOS 5  6)
is now live.

The distribution deviates from current practice. When you upgrade to a
new Platform
from justhub.org you add the new platform to your Haskell
infrastructure rather than
replacing the old platform with a new one.

Why?

**Stability**: Enterprise Linux places a strong emphasis on stability
and updating
packages should not break things. (This has provided some challenges for us as
RHEL 5 is still using GCC  4.1.2 and Binutils 2.17.50.)

**Flexibility**: Different projects will in general need to work with
different versions of the
platform and toolkits and upgrade according to their own schedules. I
believe Haskell’s
strong-typing sharpens the need for this. Production projects will
need to upgrade
according to their own schedules while other projects will want to
stay up-to-date.
In general when you check out a source tree you want to build with the tools and
libraries that it has been tested with and move on according to the
project’s timetable.

**Sandboxes**: The same mechanism for managing the multiple toolkits
and platforms
can be adapted to provide an integrated sandbox utility. The logic
that dictates that
projects have different tool-chain requirements applies to the user
packages too.
(‘Handbox’ doesn’t really work so we use **Hubs** instead.)

**Package Deletion**: The infrastructure can also be expanded to complete the
package management tools with package removal and garbage collection
of library code.

**The Catalogue**: All of the GHC releases can be added as they become
available.

In general the distribution works just like any other – after an
upgrade invoking ‘ghc’
without any other configuration will invoke the compiler for that
latest platform, which
should behave as it would on any other (working) distribution.

But after an upgrade:

 o any projects configured to work with specific tool chains and
libraries will continue
undisturbed;

 o you can create a new hub based on the new platform and experiment with it on
newly-checked-out source tree without disturbing an existing
working tree (or
just swap the hub into an existing work tree and back out again if
things don’t
work out);

 o even on release of a new version of a package (or if you want to
experiment with
your existing packages) you can easily duplicate an existing hub and delete,
upgrade and add packages on a topic branch.

Of course ‘serious developers’ have been doing this with home-brew
infrastructure
for ever. Nevertheless I have found doing it with well-integrated
tools to be quite liberating.

It might also help new users to make the transition to serious
developers more quickly.

Thoughts anyone?

Chris

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] proxy settings with simpleHttp

2012-01-02 Thread hanjoosten
Hi,

I am fiddling around with the package http-enumerator to download web pages.
I was used to `simpleHttp` do do that. However, I would like to infuence the
proxy settings, because sometimes I am behind a firewall. 

Is there a simple way to do this?

Thanks!

Han.

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/proxy-settings-with-simpleHttp-tp5114946p5114946.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


Re: [Haskell-cafe] proxy settings with simpleHttp

2012-01-02 Thread Michael Snoyman
On Mon, Jan 2, 2012 at 6:31 PM, hanjoosten han.joos...@atos.net wrote:
 Hi,

 I am fiddling around with the package http-enumerator to download web pages.
 I was used to `simpleHttp` do do that. However, I would like to infuence the
 proxy settings, because sometimes I am behind a firewall.

 Is there a simple way to do this?

 Thanks!

 Han.

 --
 View this message in context: 
 http://haskell.1045720.n5.nabble.com/proxy-settings-with-simpleHttp-tp5114946p5114946.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

You'll need to drop down one layer and use httpLbsRedirect. You can
look at the code of simpleHttp[1] and add your proxy settings there.
Do people think it would be a good idea to expose an extra function
that has the same semantics as simpleHttp but takes a Request instead
of a String? Any ideas on names?

Michael

[1] 
http://hackage.haskell.org/packages/archive/http-conduit/1.0.0/doc/html/src/Network-HTTP-Conduit.html#simpleHttp

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Experiments in Haskell Packaging

2012-01-02 Thread Chris Dornan
[I am sorry for if get two copies of this -- no sign of the first copy.]

The justhub.org Haskell distribution for Enterprise Linux (RHEL/CentOS
5  6) is now live.

The distribution deviates from current practice. When you upgrade to a
new Haskell Platform you add the new platform to your Haskell
infrastructure rather than replacing the old platform with a new one.

Why?

•   Stability: Enterprise Linux places a strong emphasis on stability
and updating packages should not break things. (This has provided some
challenges for us as RHEL 5 is still using GCC  4.1.2 and Binutils
2.17.50.)

•   Flexibility: Different projects will in general need to work with
different versions of the platform and toolkits and upgrade according
to their own schedules. I believe Haskell’s strong-typing sharpens the
need for this. Production projects will need to upgrade according to
their own schedules while other projects will want to stay up-to-date.
In general when you check out a source tree you want to build with the
tools and libraries that it has been tested with and move on according
to the project’s timetable.

•   Sandboxes: The same mechanism for managing the multiple toolkits and
platforms can be adapted to provide an integrated sandbox utility. The
logic that dictates that projects have different tool-chain
requirements applies to the user packages too. (‘Handbox’ doesn’t
really work so we use Hubs instead.)

•   Package Deletion: The infrastructure can also be expanded to
complete the package management tools with package removal and garbage
collection of library code.

•   The Catalogue: All of the GHC releases can be added as they become 
available.

In general the distribution works just like any other – after an
upgrade invoking ‘ghc’ without any other configuration will invoke the
compiler for that latest platform, which should behave as it would on
any other (working) distribution.

But after an upgrade:

•   any projects configured to work with specific tool chains and
libraries will continue undisturbed;

•   you can create a new hub based on the new platform and experiment
with it on newly-checked-out source tree without disturbing an
existing working tree (or just swap the hub into an existing work tree
and back out again if things don’t work out);

•   even on release of a new version of a package (or if you want to
experiment with your existing packages) you can easily duplicate an
existing hub and delete, upgrade and add packages on a topic branch.

Of course ‘serious developers’ have been doing this with home-brew
infrastructure for ever. Nevertheless I have found doing it with
well-integrated tools to be quite liberating.

It might also help new users to make the transition to serious
developers more quickly.

Thoughts anyone?

Chris

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Markus Läll
String is really for small strings. Text is more efficent and also has
more functionality, including most, if not all, of the functions
defined for String.

On Mon, Jan 2, 2012 at 3:12 PM, Anupam Jain ajn...@gmail.com wrote:
 On Mon, Jan 2, 2012 at 5:52 PM, Felipe Almeida Lessa
 felipe.le...@gmail.com wrote:
 On Mon, Jan 2, 2012 at 10:12 AM, max m...@mtw.ru wrote:
 This is the simplest solution of the proposed, in my opinion. Thank you
 very much.

 Better yet, don't use String and use Text.  Then you just need
 T.splitOn \r\n [1].

 That is actually the opposite of what the OP wants, however it's
 interesting that Text has a function like that and not the String
 functions in the standard
 library.

 -- Anupam

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Markus Läll

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] space-efficient, composable list transformers [was: Re: Reifying case expressions]

2012-01-02 Thread Jan Christiansen
Hi,

On Jan 2, 2012, at 2:34 PM, Heinrich Apfelmus wrote:

 Without an explicit guarantee that the function is incremental, we can't do 
 anything here. But we can just add another constructor to that effect if we 
 turn  ListTo  into a GADT:
 
data ListTo a b where
CaseOf   :: b -  (a - ListTo a b)  - ListTo a b
Fmap :: (b - c) - ListTo a b   - ListTo a c
 
FmapCons :: b - ListTo a [b] - ListTo a [b]

I did not follow your discussion but how about using an additional GADT for the 
argument of Fmap, that is

data Fun a b where
  Fun :: (a - b) - Fun a b
  Cons :: a - Fun [a] [a]

data ListTo a b where
  CaseOf   :: b -  (a - ListTo a b) - ListTo a b
  Fmap :: Fun b c - ListTo a b   - ListTo a c

and provide a function to interpret this data type as well

interpretFun :: Fun a b - a - b
interpretFun (Fun f)  = f
interpretFun (Cons x) = (x:)

for the sequential composition if I am not mistaken.

(.) :: ListTo b c - ListTo a [b] - ListTo a c
(CaseOf _ cons) . (Fmap (Cons y) b) = cons y . b
(Fmap f a)  . (Fmap g b) = Fmap f $ a . (Fmap g b)
a . (CaseOf nil cons)= CaseOf (interpret a nil) ((a .) . cons)
a . (Fmap f b)   = fmap (interpret a . interpretFun f) b


-- functor instance
instance Functor (ListTo a) where
  fmap f = normalize . Fmap (Fun f)

normalize :: ListTo a b - ListTo a b
normalize (Fmap (Fun f) (Fmap (Fun g) c)) = fmap (f . g) c
normalize x = x

Cheers, Jan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] On the purity of Haskell

2012-01-02 Thread Conal Elliott
On 2012/1/1 Ertugrul Söylemez e...@ertes.de wrote:

 Steve Horne sh006d3...@blueyonder.co.uk wrote:
  Of course even the bind operator arguably isn't primitive. We could
  translate to get rid of those too, and see what lies underneath. This
  is where we start seeing functions of type...
 
 World - (x, World)
 
  Problem - this level of abstraction is hypothetical. It is not part of
  the Haskell language. Haskell specifically defines the IO monad to be
  a black box.

 And that's fine, because IO is an embedded DSL.  A better view of IO is
 a GADT like:

data IO :: * - * where
GetLine  :: IO String
PutStrLn :: String - IO ()
...

 This is still hypothetical, but it shows how even IO is easily
 referentially transparent (as long as you don't use unsafe* cheats).


What?? I see how a definition like this one shows how something else that
you call IO can be denotative  RT. I don't see how what that conclusion
has to do with Haskell's IO.

I also wonder whether you're assuming that all of the IO primitives we have
in Haskell treat their non-IO arguments denotationally/extensionally, so
that there cannot be operations like isWHNF :: a - IO Bool.

  - Conal
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] porting feed to xml-enumerator

2012-01-02 Thread Simon Michael
Hi Sigbjorn (and Don),

I'm back for another reason. feed leaks and uses a lot of memory due to the xml 
package. Rather than fix xml I ported feed to xml-enumerator, which is used by 
yesod and more actively maintained than xml. This seems to have fixed the 
problem so I'm thinking of uploading this version to hackage as feed-1.0 (which 
I'll use for rss2irc and hackagebot.)

Please let me know whether you agree. Also you might be interested in moving 
your repo (http://code.galois.com/cgi-bin/gitweb?p=feed.git;a=summary) to 
github ? This would make it easier to publish my changes, either to the main 
repo or a branch or fork. Otherwise I'll need to get them to your repo somehow.

Thanks again,
-Simon



On Feb 21, 2011, at 5:14 PM, Simon Michael wrote:
 thanks for feed. I'm just investigating a bug with rss2irc, and I think I'm 
 seeing problems in the current feed on hackage. It lookas as if there's no 
 way to get item updated date as opposed item published date, and 
 getItemPublishDate actually gets the updated date in the case of an atom feed 
 (http://hackage.haskell.org/packages/archive/feed/0.3.8/doc/html/src/Text-Feed-Query.html#getItemPublishDate).
 
 I'd like to contribute a fix. Would you be able to make feed's repo public, 
 eg on darcsden.com or github ?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] porting feed to xml-enumerator

2012-01-02 Thread Michael Snoyman
If I may: I'm about to upload a new version of xml-enumerator that
will state that it's officially deprecated in favor of xml-conduit. My
guess is you'll be able to migrate to the latter by just changing the
package name in your cabal file.

On Mon, Jan 2, 2012 at 8:54 PM, Simon Michael si...@joyful.com wrote:
 Hi Sigbjorn (and Don),

 I'm back for another reason. feed leaks and uses a lot of memory due to the
 xml package. Rather than fix xml I ported feed to xml-enumerator, which is
 used by yesod and more actively maintained than xml. This seems to have
 fixed the problem so I'm thinking of uploading this version to hackage as
 feed-1.0 (which I'll use for rss2irc and hackagebot.)

 Please let me know whether you agree. Also you might be interested in moving
 your repo (http://code.galois.com/cgi-bin/gitweb?p=feed.git;a=summary) to
 github ? This would make it easier to publish my changes, either to the main
 repo or a branch or fork. Otherwise I'll need to get them to your repo
 somehow.

 Thanks again,
 -Simon



 On Feb 21, 2011, at 5:14 PM, Simon Michael wrote:

 thanks for feed. I'm just investigating a bug with rss2irc, and I think I'm
 seeing problems in the current feed on hackage. It lookas as if there's no
 way to get item updated date as opposed item published date, and
 getItemPublishDate actually gets the updated date in the case of an atom
 feed
 (http://hackage.haskell.org/packages/archive/feed/0.3.8/doc/html/src/Text-Feed-Query.html#getItemPublishDate).

 I'd like to contribute a fix. Would you be able to make feed's repo public,
 eg on darcsden.com or github ?



 ___
 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] porting feed to xml-enumerator

2012-01-02 Thread Aristid Breitkreuz
Hi Simon and all,

You might want to consider using xml-conduit instead of
xml-enumerator. Michael Snoyman has shifted his attention to this new
alternative.

Cheers,

Aristid


2012/1/2 Simon Michael si...@joyful.com:
 Hi Sigbjorn (and Don),

 I'm back for another reason. feed leaks and uses a lot of memory due to the
 xml package. Rather than fix xml I ported feed to xml-enumerator, which is
 used by yesod and more actively maintained than xml. This seems to have
 fixed the problem so I'm thinking of uploading this version to hackage as
 feed-1.0 (which I'll use for rss2irc and hackagebot.)

 Please let me know whether you agree. Also you might be interested in moving
 your repo (http://code.galois.com/cgi-bin/gitweb?p=feed.git;a=summary) to
 github ? This would make it easier to publish my changes, either to the main
 repo or a branch or fork. Otherwise I'll need to get them to your repo
 somehow.

 Thanks again,
 -Simon



 On Feb 21, 2011, at 5:14 PM, Simon Michael wrote:

 thanks for feed. I'm just investigating a bug with rss2irc, and I think I'm
 seeing problems in the current feed on hackage. It lookas as if there's no
 way to get item updated date as opposed item published date, and
 getItemPublishDate actually gets the updated date in the case of an atom
 feed
 (http://hackage.haskell.org/packages/archive/feed/0.3.8/doc/html/src/Text-Feed-Query.html#getItemPublishDate).

 I'd like to contribute a fix. Would you be able to make feed's repo public,
 eg on darcsden.com or github ?



 ___
 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

2012-01-02 Thread James Cook
On Jan 2, 2012, at 1:30 PM, Conal Elliott wrote:

 On 2012/1/1 Ertugrul Söylemez e...@ertes.de wrote:
 
 And that's fine, because IO is an embedded DSL.  A better view of IO is
 a GADT like:
 
data IO :: * - * where
GetLine  :: IO String
PutStrLn :: String - IO ()
...
 
 This is still hypothetical, but it shows how even IO is easily
 referentially transparent (as long as you don't use unsafe* cheats).
 
 What?? I see how a definition like this one shows how something else that you 
 call IO can be denotative  RT. I don't see how what that conclusion has to 
 do with Haskell's IO.

Whether you say such a beast is IO or something else that you call 'IO', I 
don't see the problem with positing an open GADT of this form, new constructors 
of which are introduced by built-in magic and/or by 'foreign import', and 
letting the denotation of IO be terms in the free algebraic theory on the 
resulting signature.  It is then the job of the compiler, linker, et al, to 
implement a model of that algebraic theory in the machine language.  Foreign 
imports introduce new external names - constructors of the GADT  - and the 
linker connects those names to their implementations - giving them 
denotations as terms in the target machine's language.  Maybe I'm missing 
something but, in the presence of FFI, how can the world-interfacing portion of 
a programming language possibly be any more denotative than that?

Once you cross that threshold, I'd much rather have an operational semantics 
anyway.  Ultimately, programming a computer is about making the computer _do_ 
things.  No matter what sort of denotational semantics you come up with, I 
don't see any way to avoid it eventually bottoming out at some abstract 
representation which must then either have an operational semantics or an 
informal everyone who matters knows what that means semantics.  Eventually, 
the denotation of anything that potentially involves interaction with the real 
world must be a program in some real or imaginary machine's language.  This 
model chooses a very reasonable place to sever the infinite tower of turtles 
because it produces a language that is universal:  it is the free algebra of 
the signature specified by the GADT.

Incidentally, this model also addresses a concern I've heard voiced before that 
IO isn't demonstrably a monad.  The whole point of IO is, as I understand it, 
that it is a monad _by construction_ - specifically, it is the monad whose 
Kleisli category is the category of contexts and substitutions in the free 
algebraic theory generated on this signature.  There are even at least 2 
published implementations of this construction in Haskell - the MonadPrompt and 
operational packages - and it has been shown that it does, in fact, form a 
monad.  I would assert that if there is any sense in which the IO type 
_implementation_ fails to be a monad, it is a bug and not a flaw in the concept 
of an IO monad.

 I also wonder whether you're assuming that all of the IO primitives we have 
 in Haskell treat their non-IO arguments denotationally/extensionally, so that 
 there cannot be operations like isWHNF :: a - IO Bool.

Correct me if I'm wrong, but it appears the implication here is that [[isWHNF 
x]] /= [[isWHNF]] [[x]].  I don't think this is necessarily true though.  
Somewhere in any formal model of any language which takes the real world into 
account, there must be some translation from a denotational semantics to an 
operational one.  If the denotational semantics is not computable, that 
translation necessarily must introduce some kind of accidental extra state.  
The denotational semantics will generally include no concept of this state, so 
no denotation can mention it.  But I see no problem in there being a value in 
the denotation which is translated to an operation which does make use of this 
state.  In this model, [[isWHNF x]] is something like IsWHNF [[x]], which the 
compiler then translates into some code that, at run time, checks the progress 
of the attempt to compute the denotation of x.  At no point is there a term 
whose denotation depends on that state; instead, there is a computation which 
chooses how to proceed to do based on that state.

This does not infect the denotation with the forbidden knowledge, it only 
allows you to denote operations which are aware of the mechanism by which the 
denotation is computed.  Similarly, the operations 'peek' and 'poke' allow you 
to denote operations which may do unspeakably evil things at runtime, including 
entirely subverting that mechanism.  That doesn't mean the denotation is wrong, 
it means the machine has a back door.  Certainly it would be better, all other 
things being equal, if the translation did not open the back door like that 
but, as is so often the case, all other things are not equal.  The FFI and the 
occasional heinous performance hack are far too useful for most people to ever 
consider throwing out.

This may mean 

[Haskell-cafe] More cabal install problems

2012-01-02 Thread Victor Miller
I've been trying to install threadscope on my macbook pro runing OSX 10.7
(Lion).  This hasn't been easy.

Thanks to help here, I finally got glib installed, but now one of the
hangups is in installing the package gio.  The following happens:

Building gio-0.12.2...
Building library...
creating dist/build
/usr/bin/ghc --make -package-name gio-0.12.2 -hide-all-packages
-fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen
-Idist/build/autogen -Idist/build -Idist/build/autogen -Idist/build
-I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include -optP-include -optPdist/build/autogen/cabal_macros.h
-odir dist/build -hidir dist/build -stubdir dist/build -package-id
array-0.3.0.2-143060371bda4ff52c270d1067551fe8 -package-id
base-4.3.1.0-239d76b73f466dc120129098b3472858 -package-id
bytestring-0.9.1.10-5bb17614aed376ea31b721a9272770b1 -package-id
containers-0.4.0.0-b4885363abca642443ccd842502a3b7e -package-id
glib-0.12.2-185c12da89238d25c489c0b80fc015c5 -package-id
mtl-2.0.1.0-5b7a9cce5565d8cc8721ba4f95becf1b -O -XHaskell98
-XForeignFunctionInterface System.GIO System.GIO.Enums System.GIO.Types
System.GIO.Async.AsyncResult System.GIO.Signals
System.GIO.Async.Cancellable System.GIO.File.AppInfo
System.GIO.File.ContentType System.GIO.File.FileAttribute
System.GIO.File.File System.GIO.File.FileEnumerator
System.GIO.File.FileInfo System.GIO.File.FileMonitor
System.GIO.File.IOError System.GIO.File.MountOperation
System.GIO.Icons.Emblem System.GIO.Icons.EmblemedIcon
System.GIO.Icons.FileIcon System.GIO.Icons.Icon System.GIO.Icons.ThemedIcon
System.GIO.Volumes.Drive System.GIO.Volumes.Mount System.GIO.Volumes.Volume
System.GIO.Volumes.VolumeMonitor
command line: cannot satisfy -package-id
mtl-2.0.1.0-5b7a9cce5565d8cc8721ba4f95becf1b
(use -v for more information)
World file is already up to date.
cabal: Error: some packages failed to install:
gio-0.12.2 failed during the building phase. The exception was:
ExitFailure 1



---

However, cabal list tells me:

* mtl
Synopsis: Monad classes, using functional dependencies
Default available version: 2.0.1.0
Installed versions: 2.0.1.0
License:  BSD3


which tells me that the version of mtl that's desired is already
installed.  Any suggestions?

Victor
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More cabal install problems

2012-01-02 Thread Brandon Allbery
On Mon, Jan 2, 2012 at 21:36, Victor Miller victorsmil...@gmail.com wrote:

 command line: cannot satisfy -package-id
 mtl-2.0.1.0-5b7a9cce5565d8cc8721ba4f95becf1b
 (use -v for more information)

 However, cabal list tells me:

 * mtl
 Synopsis: Monad classes, using functional dependencies
 Default available version: 2.0.1.0
 Installed versions: 2.0.1.0
 License:  BSD3


The right version, but possibly not the right ABI hash.  Also, it might be
broken by some other dependency; try ghc-pkg list which should give you
an idea about both issues.  ghc is regrettably not very good about saying
*why* it cannot satisfy a package dependency.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More cabal install problems

2012-01-02 Thread Victor Miller
Brandon, Thanks again.  That put me on the right track.   When I did a
ghc-pkg list it added a message saying that the cache was out of date and
that I should run ghc-pkg recache.  I did that and gio appears to
installing.

Victor

On Mon, Jan 2, 2012 at 9:49 PM, Brandon Allbery allber...@gmail.com wrote:

 On Mon, Jan 2, 2012 at 21:36, Victor Miller victorsmil...@gmail.comwrote:

 command line: cannot satisfy -package-id
 mtl-2.0.1.0-5b7a9cce5565d8cc8721ba4f95becf1b
 (use -v for more information)

 However, cabal list tells me:

 * mtl
 Synopsis: Monad classes, using functional dependencies
 Default available version: 2.0.1.0
 Installed versions: 2.0.1.0
 License:  BSD3


 The right version, but possibly not the right ABI hash.  Also, it might be
 broken by some other dependency; try ghc-pkg list which should give you
 an idea about both issues.  ghc is regrettably not very good about saying
 *why* it cannot satisfy a package dependency.

 --
 brandon s allbery  allber...@gmail.com
 wandering unix systems administrator (available) (412) 475-9364 vm/sms


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Avoiding parametric function binding

2012-01-02 Thread Kevin Quick
On Sun, 01 Jan 2012 05:29:42 -0700, Sebastian Fischer fisc...@nii.ac.jp  
wrote:

On Sat, Dec 31, 2011 at 4:09 PM, Kevin Quick qu...@sparq.org wrote:
 onVarElem :: forall a . (Show a) = (Maybe a - String) - Var -  
String


The problem is the scope of the quantification of the type variable 'a'.
You can use higher-rank types (via the Rank2Types or RankNTypes language
extension) to achieve what you want. Change the type of 'onVarElem' to

onVarElem :: (forall a . (Show a) = Maybe a - String) - Var -  
String


Thanks to both Sebastian and Sean for the solution (abbreviated from  
Sebastian's reponse above).


-Kevin

P.S.  Sorry for the late followup: some minor system issues prevented  
checking email for a little while.  The delay notwithstanding, *all* of  
the responses were much appreciated.


--
-KQ

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe