Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Can't install json-.0.4.4 - memory   allocation failed
      (Dan Tenenbaum)
   2. Re:  type signature error in a where clause (Kim-Ee Yeoh)


----------------------------------------------------------------------

Message: 1
Date: Sat, 24 Nov 2012 11:12:44 -0800
From: Dan Tenenbaum <[email protected]>
Subject: Re: [Haskell-beginners] Can't install json-.0.4.4 - memory
        allocation failed
To: Brandon Allbery <[email protected]>
Cc: "peter.hall" <[email protected]>,    "[email protected]"
        <[email protected]>
Message-ID:
        <CAF42j22qi5hRGA_P1oFVypVrZuNF=uth9oaqfauk7lthnno...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Updating GHC by building it from source seemed to to the trick. I was
then able to install the latest pandoc and dependencies. It was
suggested I install GHC 7.4.2 rather than 7.6.* so that's what I did.
Thanks,
Dan


On Wed, Nov 21, 2012 at 3:24 PM, Dan Tenenbaum <[email protected]> wrote:
> It's not a PPC machine, it's an Intel Machine.
> The only Haskell Platform installer for Mac OS 10.5 that I have found
> is at the bottom of:
> http://www.haskell.org/platform/mac.html
> It's labeled  2010.2.0.0.
>
> I don't think I have any old port installations hanging out messing
> things up (though I'll doublecheck). For one thing, /opt/local (where
> port installs things) is not in the PATH. I've never used brew on this
> machine,
>
> I tried passing some parameters to use the compacting collector, and
> to set the heap size, as suggested by this post:
> http://stackoverflow.com/questions/13479538/cant-install-json-0-4-4-memory-allocation-failed
>
> Unfortunately I get the same results (I set heap size to 4095MB, the
> largest I'm allowed to set it).
> Doesn't seem to matter whether the compacting collector is used or not.
>
> Dan
>
> On Wed, Nov 21, 2012 at 3:07 PM, Brandon Allbery <[email protected]> wrote:
>> On Wed, Nov 21, 2012 at 6:00 PM, Peter Hall <[email protected]>
>> wrote:
>>>
>>> OSX 10.5.8 isn't THAT old. You can definitely get a Haskell Platform 7.x
>>
>>
>> PPC might be, though.
>>
>> --
>> brandon s allbery kf8nh                               sine nomine associates
>> [email protected]                                  [email protected]
>> unix/linux, openafs, kerberos, infrastructure          http://sinenomine.net
>>



------------------------------

Message: 2
Date: Sun, 25 Nov 2012 16:34:15 +0700
From: Kim-Ee Yeoh <[email protected]>
Subject: Re: [Haskell-beginners] type signature error in a where
        clause
To: Mark Wallace <[email protected]>
Cc: [email protected], Daniel Fischer
        <[email protected]>
Message-ID:
        <capy+zdsob0efq3kbmmv-7y3uus47qjqnmqpf7fgo1ks54_g...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Sat, Nov 24, 2012 at 10:32 PM, Mark Wallace <[email protected]> wrote:

> > Somehow it might seem a bit easier to me to grasp the function of a
function with the help of type signature. I'll try just omitting the
signatures, it's easier and more handy isn't it?

The unspoken wisdom goes something like this: the classic top-down FP way
of coding has you sketch out most if not all of your function signatures.
So when you hit the keyboard, a very natural thing to do is to key in all
those signatures stubbing out definitions using "undefined". You proceed
from there.

Sometimes people just use haskell as a calculator on steroids, especially
when solving project-euler-type problems. In which case, anything goes.
Needless to say, if all the practice a beginner gets is project euler,
they're missing out a lot.


-- Kim-Ee


On Sat, Nov 24, 2012 at 10:32 PM, Mark Wallace <[email protected]> wrote:

> On 11/24/2012 11:07 PM, Daniel Fischer wrote:
>
>> On Samstag, 24. November 2012, 22:04:15, Mark Wallace wrote:
>>
>>> I'm writing a merge sort function, but I get type error under such
>>> implementation:
>>>
>>>      mergesort :: (a -> a -> Ordering) -> [a] -> [a]
>>>      mergesort cmp xs = mergeAll (map (\x -> [x]) xs)
>>>           where
>>>             mergeAll :: [[a]] -> [a]
>>>             mergeAll [x] = x
>>>             mergeAll xs = mergeAll (mergePairs xs)
>>>
>>>             mergePairs :: [[a]] -> [[a]]
>>>             mergePairs (a:b:xs) = merge a b : mergePairs xs
>>>             mergePairs xs = xs
>>>
>>>             merge :: [a] -> [a] -> [a]
>>>             merge as@(a:as') bs@(b:bs')
>>>
>>>                 | cmp a b == GT = b : merge as bs'
>>>                 | otherwise     = a : merge as' bs
>>>
>>>             merge [] bs = bs
>>>             merge as [] = as
>>>
>>> And ghc says:
>>>
>>>           Couldn't match type `a1' with `a'
>>>             `a1' is a rigid type variable bound by
>>>                  the type signature for merge :: [a1] -> [a1] -> [a1]
>>>                  at
>>>      /home/ice/Study/Haskell/**tutorials/99Questions/21to30.**hs:135:7
>>>             `a' is a rigid type variable bound by
>>>                 the type signature for
>>>                   mergesort :: (a -> a -> Ordering) -> [a] -> [a]
>>>                 at
>>>      /home/ice/Study/Haskell/**tutorials/99Questions/21to30.**hs:124:1
>>>           In the first argument of `cmp', namely `a'
>>>           In the first argument of `(==)', namely `cmp a b'
>>>           In the expression: cmp a b == GT
>>>
>>> But if I comment all type signatures, ghc works fine on it.
>>> I would really appreciate it if you can point out what causes this
>>> question?
>>>
>> Type variables are implicitly for all-quantified. Thus the type variable
>> a in
>> the signatures of the local functions is a fresh type variable and has
>> nothing
>> to do with the a from the top-level signature.
>>
>> It is equivalent to you writing
>>
>>      merge :: [b] -> [b] -> [b]
>>
>> except there it is obvious that the type signature is wrong.
>>
>>  And how to fix it without changing the structure of the program (i.e. not
>>>
>> adding function `cmp' as a parameter of `merge' etc.).
>>
>> 1. Just omit the type signatures, they can be inferred.
>>
>> That's the portable way.
>>
>> 2. Bring the type variable a into scope
>>
>>      {-# LANGUAGE ScopedTypeVariables #-}
>>
>>      mergesort :: forall a. (a-> a-> Ordering) -> [a] -> [a]
>>
>> then an (unquantified) a in a local type signature refers to the type
>> from the
>> top-level signature.
>>
>> That's a GHC-only (as far as I know) way.
>>
> Thanks for answering so fast. And all of your answers are very helpful.
> I've tested these two solutions, all works fine.
> Now I understand how type signature works in such condition.
>
> Somehow it might seem a bit easier to me to grasp the function of a
> function with the help of type signature.
> I'll try just omitting the signatures, it's easier and more handy isn't it?
>
>
> ______________________________**_________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121125/e8530d07/attachment-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 53, Issue 32
*****************************************

Reply via email to