Picon

Different behaviors between GHC 7.6.3 and 7.8.3

Hello everyone,

I'm quite intrigued about these different behaviors between GHCs 7.6.3 and 7.8.3:


GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let x = 3 + 4
Prelude> :print x
x = (_t1::Integer)
Prelude> :force x
x = 7
Prelude> print _t1
7
Prelude>


GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> let x = 3 + 4
Prelude> :print x
x = (_t1::Num a => a)
Prelude> :force x
x = _
Prelude> print _t1
ghc: panic! (the 'impossible' happened)
  (GHC version 7.8.3 for x86_64-unknown-linux):
    tcTyVarDetails a{tv atm} [tv]

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug


Is it really a bug or is it something I really shouldn't be doing? I've found this (fixed) bug (https://ghc.haskell.org/trac/ghc/ticket/8557), with a similar error output, but it does not seem to be the same case.

Thanks

Emilio


<div><div dir="ltr">
<div>
<div>
<div>
<div>Hello everyone, <br><br>
</div>I'm quite intrigued about these different behaviors between GHCs 7.6.3 and 7.8.3:<br><br><br>GHCi, version 7.6.3: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a>&nbsp; :? for help<br>Loading package ghc-prim ... linking ... done.<br>Loading package integer-gmp ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude&gt; let x = 3 + 4<br>Prelude&gt; :print x<br>x = (_t1::Integer)<br>Prelude&gt; :force x<br>x = 7<br>Prelude&gt; print _t1<br>7<br>Prelude&gt;<br><br><br>GHCi, version 7.8.3: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a>&nbsp; :? for help<br>Loading package ghc-prim ... linking ... done.<br>Loading package integer-gmp ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude&gt; let x = 3 + 4<br>Prelude&gt; :print x<br>x = (_t1::Num a =&gt; a)<br>Prelude&gt; :force x<br>x = _<br>Prelude&gt; print _t1<br>ghc: panic! (the 'impossible' happened)<br>&nbsp; (GHC version 7.8.3 for x86_64-unknown-linux):<br>&nbsp;&nbsp;&nbsp; tcTyVarDetails a{tv atm} [tv]<br><br>Please report this as a GHC bug:&nbsp; <a href="http://www.haskell.org/ghc/reportabug" target="_blank">http://www.haskell.org/ghc/reportabug</a><br><br><br>
</div>Is it really a bug or is it something I really shouldn't be doing? I've found this (fixed) bug (<a href="https://ghc.haskell.org/trac/ghc/ticket/8557" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/8557</a>), with a similar error output, but it does not seem to be the same case.<br><br>
</div>Thanks<br><br>
</div>Emilio<br><div><div><div>
<br><br>
</div></div></div>
</div></div>
David Raymond | 29 Sep 17:52 2014

Unformatted binary IO


I am trying to read and write to/from files or stdout/stdin that have
an ascii header followed by unformatted float32 binary data.  (The
files are created using a C program.)  The ascii header first needs to
be parsed to understand the structure of the floating point data.  I
have solved the parsing problem, but getting the unformatted binary
float data into a series of float (or double) immutable, unboxed
vectors has defeated me so far.  The binary package doesn't help as
far as I can see, as the binary format it reads and writes has some
control information at the beginning that doesn't exist in the format
I am reading.

This is easy in C, but seems to be hard in Haskell unless I am missing
something.

Any suggestions?

--

-- 
David J. Raymond
Prof. of Physics
New Mexico Tech
http://www.physics.nmt.edu/~raymond/index.html
Dontdie YCH | 29 Sep 11:27 2014
Picon

Is there a way to add package to .cabal when I import some module?

Is there a way to add package to .cabal when I import new module?
Elias Diem | 27 Sep 17:57 2014
Picon

HXT: encoding problem

Hi guys

I have got the following haskell program:

------------------------------------------------------
import Text.XML.HXT.Core

main = do
    xml <- readFile "test_data-small.xml"
    let doc = readString config xml
    res <- runX . xshow $
        doc
        >>>
        getChildren >>> isElem >>> hasName "contacts"
        >>>
        deep isText
    mapM_ putStrLn res

config =
    [ withParseHTML                 no
    , withWarnings                  yes
    , withInputEncoding             utf8
    , withOutputEncoding            utf8
    , withValidate                  yes
    ]
------------------------------------------------------

The file 'test_data-small.xml' contains the following data:

------------------------------------------------------
<?xml version='1.0' encoding='UTF-8' ?>

<contacts>

<person>
    <name>
        <firstname>Max</firstname>
        <lastname>Müller</lastname>
    </name>
</person>

</contacts>
------------------------------------------------------

Note the umlaut in the lastname!

If I run the program, I get the following error:

------------------------------------------------------
error: UTF-8 encoding error at input position 127: ValueOutOfBounds
------------------------------------------------------

Any help is appreciated. Thanks.

--

-- 
Greetings
Elias

_______________________________________________
Beginners mailing list
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners
Mateusz Kowalczyk | 27 Sep 06:20 2014
Picon

Re: aeson json paring

On 09/26/2014 03:34 PM, Miro Karpis wrote:
> Hi, I'm trying to run an example from the eason documentation
> <https://hackage.haskell.org/package/aeson-0.6.1.0/docs/Data-Aeson.html#g:3>
> :
> 
> λ> do result <- decode "{\"name\":\"Dave\",\"age\":2}"
>        flip parseMaybe result $ \obj -> do
>          age <- obj .: "age"
>          name <- obj .: "name"
>          return (name ++ ": " ++ show (age*2))
> 
> 
> I made a function:
> 
> jsonTest = do
> 	result <- decode "{\"name\":\"Dave\",\"age\":2}"
> 	flip parseMaybe result $ \obj -> do
> 		age <- obj .: "age"
> 		name <- obj .: "name"
> 		return (name ++ ": " ++ show (age*2))
> 
> which can not compile:
> hh.hs:35:41:
>     No instance for (Show a0) arising from a use of ‘show’
>     The type variable ‘a0’ is ambiguous
> ....
> ...
> 
> 
> Please what am I doing wrong?
> 
> Cheers, Miro
> 

As pointed out in the other response, you'll need a type signature
somewhere to indicate what type your ‘age’ should be.

I'd like to point out something else however. You appear to be using
hard tabs (‘\t’ character): please don't do this! Haskell is
alignment-sensitive and you'll run into problems due to this unless you
*very* strictly only insert tabs. FTR GHC treats one \t as 8 spaces.
There are beginners on daily basis in #haskell wondering why their code
doesn't compile just to discover tabs once they share it through
lpaste.net or similar service.

[1] is the standard reference for style, especially see the ‘Tabs’ section.

So, please, set your editor to only insert spaces.

[1]: http://urchin.earth.li/~ian/style/haskell.html

--

-- 
Mateusz K.
_______________________________________________
Beginners mailing list
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners
Raphaël Mongeau | 26 Sep 16:41 2014
Picon

Re: aeson json paring

The key here is "The type variable ‘a0’ is ambiguous".

You need to add a type signature to age so the compiler know if age is of type In,Float or Double ...

:)

2014-09-26 10:34 GMT-04:00 Miro Karpis <miroslav.karpis <at> gmail.com>:
Hi, I'm trying to run an example from the eason documentation:

λ> do result <- decode "{\"name\":\"Dave\",\"age\":2}" flip parseMaybe result $ \obj -> do age <- obj .: "age" name <- obj .: "name" return (name ++ ": " ++ show (age*2))


I made a function:

jsonTest = do
result <- decode "{\"name\":\"Dave\",\"age\":2}"
flip parseMaybe result $ \obj -> do
age <- obj .: "age"
name <- obj .: "name"
return (name ++ ": " ++ show (age*2))

which can not compile:
hh.hs:35:41:
No instance for (Show a0) arising from a use of ‘show’
The type variable ‘a0’ is ambiguous
....
...


Please what am I doing wrong?

Cheers, Miro



_______________________________________________
Beginners mailing list
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners




--
Viva Cila
<div>
<div dir="ltr">The key here is "<span>The type variable &lsquo;a0&rsquo; is ambiguous</span>".<br><div><br></div>
<div>You need to add a type signature to age so the compiler know if age is of type In,Float or Double ...</div>
<div><br></div>
<div>:)</div>
</div>
<div class="gmail_extra">
<br><div class="gmail_quote">2014-09-26 10:34 GMT-04:00 Miro Karpis <span dir="ltr">&lt;<a href="mailto:miroslav.karpis <at> gmail.com" target="_blank">miroslav.karpis <at> gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote">
<div dir="ltr">Hi, I'm trying to run an example from the <a href="https://hackage.haskell.org/package/aeson-0.6.1.0/docs/Data-Aeson.html#g:3" target="_blank">eason documentation</a>:<br><br>&lambda;&gt; do result &lt;- decode "{\"name\":\"Dave\",\"age\":2}"
       flip parseMaybe result $ \obj -&gt; do
         age &lt;- obj .: "age"
         name &lt;- obj .: "name"
         return (name ++ ": " ++ show (age*2))<br><br><br>I made a function:<br><br>jsonTest = do <br>	result &lt;- decode "{\"name\":\"Dave\",\"age\":2}"<br>	flip parseMaybe result $ \obj -&gt; do<br>		age &lt;- obj .: "age"<br>		name &lt;- obj .: "name"<br>		return (name ++ ": " ++ show (age*2))<br><br>which can not compile:<br>hh.hs:35:41:<br>    No instance for (Show a0) arising from a use of &lsquo;show&rsquo;<br>    The type variable &lsquo;a0&rsquo; is ambiguous<br>....<br>...<br><br><br>Please what am I doing wrong?<br><br>Cheers, Miro<br> <br><br>
</div>
<br>_______________________________________________<br>
Beginners mailing list<br><a href="mailto:Beginners <at> haskell.org">Beginners <at> haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br><br>
</blockquote>
</div>
<br><br clear="all"><div><br></div>-- <br>Viva Cila
</div>
</div>
Miro Karpis | 26 Sep 16:34 2014
Picon

aeson json paring

Hi, I'm trying to run an example from the eason documentation:

λ> do result <- decode "{\"name\":\"Dave\",\"age\":2}" flip parseMaybe result $ \obj -> do age <- obj .: "age" name <- obj .: "name" return (name ++ ": " ++ show (age*2))


I made a function:

jsonTest = do
result <- decode "{\"name\":\"Dave\",\"age\":2}"
flip parseMaybe result $ \obj -> do
age <- obj .: "age"
name <- obj .: "name"
return (name ++ ": " ++ show (age*2))

which can not compile:
hh.hs:35:41:
No instance for (Show a0) arising from a use of ‘show’
The type variable ‘a0’ is ambiguous
....
...


Please what am I doing wrong?

Cheers, Miro


<div><div dir="ltr">Hi, I'm trying to run an example from the <a href="https://hackage.haskell.org/package/aeson-0.6.1.0/docs/Data-Aeson.html#g:3">eason documentation</a>:<br><br>&lambda;&gt; do result &lt;- decode "{\"name\":\"Dave\",\"age\":2}"
       flip parseMaybe result $ \obj -&gt; do
         age &lt;- obj .: "age"
         name &lt;- obj .: "name"
         return (name ++ ": " ++ show (age*2))<br><br><br>I made a function:<br><br>jsonTest = do <br>	result &lt;- decode "{\"name\":\"Dave\",\"age\":2}"<br>	flip parseMaybe result $ \obj -&gt; do<br>		age &lt;- obj .: "age"<br>		name &lt;- obj .: "name"<br>		return (name ++ ": " ++ show (age*2))<br><br>which can not compile:<br>hh.hs:35:41:<br>    No instance for (Show a0) arising from a use of &lsquo;show&rsquo;<br>    The type variable &lsquo;a0&rsquo; is ambiguous<br>....<br>...<br><br><br>Please what am I doing wrong?<br><br>Cheers, Miro<br> <br><br>
</div></div>
Miroslav Karpis | 23 Sep 13:04 2014
Picon

fresh install - cabal version confusion

Hi, please can you help me with following? I’m having some issues with a Haskell upgrade. 
Before upgrade I have uninstalled Haskell, removed directory + removed .ghc and .cabal files. After I install haskell and run cabal –V I get the output below. Confusing is the versions cabal returns: cabal-install version 1.18.0.5 using version 1.18.1.4? I have tried to run also cabal update, what installed 1.20.0.3, but I still got the same output. What does it mean?

I’m running on Mac.


**********************************************************************
=== Configuration for cabal has been written to
    /Users/miro/.cabal/config

=== Executables will be installed in:
    /Users/miro/Library/Haskell/bin

    You may wish to place this on your PATH by adding the following
    line to your ~/.bash_profile:

    export PATH="$HOME/Library/Haskell/bin:$PATH"

=== When documentation is built, a master index to all documentation
    will be placed in:

    /Users/miro/Library/Haskell/doc/index.html

    You may wish to bookmark that file once it gets built (after the
    first cabal install).

**********************************************************************

Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
cabal-install version 1.18.0.5
using version 1.18.1.4 of the Cabal library 
<div>
<div>Hi, please can you help me with following? I&rsquo;m having some issues with a Haskell upgrade.&nbsp;</div>
<div>Before upgrade I have uninstalled Haskell, removed directory + removed .ghc and .cabal files. After I install haskell and run cabal &ndash;V I get the output below. Confusing is the versions cabal returns: cabal-install version 1.18.0.5 using version 1.18.1.4? I have tried to run also cabal update, what installed 1.20.0.3, but I still got the same output. What does it mean?</div>
<div><br></div>
<div>I&rsquo;m running on Mac.</div>
<div><br></div>
<div>
<div><br></div>
<div>**********************************************************************</div>
<div>=== Configuration for cabal has been written to</div>
<div>&nbsp; &nbsp; /Users/miro/.cabal/config</div>
<div><br></div>
<div>=== Executables will be installed in:</div>
<div>&nbsp; &nbsp; /Users/miro/Library/Haskell/bin</div>
<div><br></div>
<div>&nbsp; &nbsp; You may wish to place this on your PATH by adding the following</div>
<div>&nbsp; &nbsp; line to your ~/.bash_profile:</div>
<div><br></div>
<div>&nbsp; &nbsp; export PATH="$HOME/Library/Haskell/bin:$PATH"</div>
<div><br></div>
<div>=== When documentation is built, a master index to all documentation</div>
<div>&nbsp; &nbsp; will be placed in:</div>
<div><br></div>
<div>&nbsp; &nbsp; /Users/miro/Library/Haskell/doc/index.html</div>
<div><br></div>
<div>&nbsp; &nbsp; You may wish to bookmark that file once it gets built (after the</div>
<div>&nbsp; &nbsp; first cabal install).</div>
<div><br></div>
<div>**********************************************************************</div>
<div><br></div>
<div>Downloading the latest package list from hackage.haskell.org</div>
<div>Note: there is a new version of cabal-install available.</div>
<div>To upgrade, run: cabal install cabal-install</div>
<div>cabal-install version 1.18.0.5</div>
<div>using version 1.18.1.4 of the Cabal library&nbsp;</div>
</div>
</div>
Dimitri DeFigueiredo | 21 Sep 19:05 2014
Picon

what space leak could happen here?

Hi All,

I was looking at the definition of intersperse on

http://hackage.haskell.org/package/base-4.7.0.1/docs/src/Data-List.html#intersperse

And found this

-- | The 'intersperse' function takes an element and a list and
-- \`intersperses\' that element between the elements of the list.
-- For example,
--
-- > intersperse ',' "abcde" == "a,b,c,d,e"

intersperse             :: a -> [a] -> [a]
intersperse _   []      = []
intersperse sep (x:xs)  = x : prependToAll sep xs


-- Not exported:
-- We want to make every element in the 'intersperse'd list available
-- as soon as possible to avoid space leaks. Experiments suggested that
-- a separate top-level helper is more efficient than a local worker.
prependToAll            :: a -> [a] -> [a]
prependToAll _   []     = []
prependToAll sep (x:xs) = sep : x : prependToAll sep xs



I don't understand why we need to "make every element in the 'intersperse'd list available as soon as possible to avoid space leaks." Could somebody shed some light on what could cause a space leak here? In particular, would this simpler version cause problems?

intersperse :: a -> [a] -> [a]
intersperse _ []  = []
intersperse _ [x] = [x]
intersperse a (x: xs <at> (y:ys)) = x : a : intersperse a xs 



Thanks,


Dimitri



<div>
    Hi All,<br><br>
    I was looking at the definition of intersperse on<br><br><a class="moz-txt-link-freetext" href="http://hackage.haskell.org/package/base-4.7.0.1/docs/src/Data-List.html#intersperse">http://hackage.haskell.org/package/base-4.7.0.1/docs/src/Data-List.html#intersperse</a><br><br>
    And found this<br><br>
    -- | The 'intersperse' function takes an element and a list and<br>
    -- \`intersperses\' that element between the elements of the list.<br>
    -- For example,<br>
    --<br>
    -- &gt; intersperse ',' "abcde" == "a,b,c,d,e"<br><br>
    intersperse&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :: a -&gt; [a] -&gt; [a]<br>
    intersperse _&nbsp;&nbsp; []&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = []<br>
    intersperse sep (x:xs)&nbsp; = x : prependToAll sep xs<br><br><br>
    -- Not exported:<br>
    -- We want to make every element in the 'intersperse'd list
    available<br>
    -- as soon as possible to avoid space leaks. Experiments suggested
    that<br>
    -- a separate top-level helper is more efficient than a local
    worker.<br>
    prependToAll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :: a -&gt; [a] -&gt; [a]<br>
    prependToAll _&nbsp;&nbsp; []&nbsp;&nbsp;&nbsp;&nbsp; = []<br>
    prependToAll sep (x:xs) = sep : x : prependToAll sep xs<br><br><br><br>
    I don't understand why we need to "make every element in the
    'intersperse'd list available as soon as possible to avoid space
    leaks." Could somebody shed some light on what could cause a space
    leak here? In particular, would this simpler version cause problems?<br><br>
    intersperse :: a -&gt; [a] -&gt; [a]<br>
    intersperse _ []&nbsp; = []<br>
    intersperse _ [x] = [x]<br>
    intersperse a (x: xs <at> (y:ys)) = x : a : intersperse a xs&nbsp; <br><br><br><br>
    Thanks,<br><br><br>
    Dimitri<br><br><br><br>
</div>
Derek McLoughlin | 21 Sep 16:02 2014
Picon

Using a monadic operation in a list comprehension.

Hi,

I'm trying to get Graham Hutton's "Programming with Effects" article
(http://www.cs.nott.ac.uk/~gmh/monads) working with Data.Tree instead
of the Tree he provides.

My code is here:

https://gist.github.com/derekmcloughlin/95ab690e0c07c5a7221e

The compiler is complaining about the use of

   lab <- mlabel c

in the list comprehension:

Couldn't match expected type ‘[Tree (a, Int)]’
                with actual type ‘ST (Tree (a, Int))’

This makes sense, but is there any way to execute the monad operation
"mlabel" within the list comprehension? I've tried the
MonadComprehensions extension but still get an error.

Derek.
_______________________________________________
Beginners mailing list
Beginners <at> haskell.org
http://www.haskell.org/mailman/listinfo/beginners
James Toll | 20 Sep 03:48 2014

Patch source, then pickup compile

Hi,

I’m trying to install Hakyll within a cabal sandbox.  The issue I’m running into is that the current
version of Pandoc doesn’t build because of this bug:

https://github.com/jgm/pandoc/issues/1590

The bug is a simple fix, and is fixed on github, but not in the version on hackage.  I’d like to use ‘cabal
get’ to download the source, manually fix the source, then compile.  The question I have is how do I pick up
the installation process after fixing the source?

So far this is what I’ve done:

$ mkdir hakyll
$ cabal update
$ cd hakyll
$ cabal sandbox init --sandbox .
$ cabal install -j hakyll
[this is the spot where pandoc fails to install]
$ cabal get pandoc-1.13.1
$ cd pandoc-1.13.1/
[patch the source]

At this point I need to resume the compilation and installation process.  How do I do that?  Do I move back up to
the parent directory and then issue the 'cabal install -j hakyll’ command again?

Thanks,

James

Gmane