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: "downcasting" (Jamie F Olson)
2. cabal install local troubles (osx) (Miro Karpis)
3. Re: cabal install local troubles (osx) (Emmanuel Touzery)
4. Re: cabal install local troubles (osx) (Miro Karpis)
5. Re: "downcasting" (Daniel Trstenjak)
6. Re: cabal install local troubles (osx) (Miro Karpis)
----------------------------------------------------------------------
Message: 1
Date: Tue, 26 Mar 2013 22:49:11 +0000 (UTC)
From: Jamie F Olson <[email protected]>
Subject: Re: [Haskell-beginners] "downcasting"
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Andres L?h <andres <at> well-typed.com> writes:
>
> Hi Emmanuel.
>
> It's somewhat confusing that in Haskell, data constructors and
> datatypes can have the same name. They're nevertheless different
> beasts. A data constructor is a way to construct values of a datatype,
> or to destruct them via pattern matching. Such constructors themselves
> are *not* types.
>
> The definition of JSValue looks as follows:
>
> > data JSValue
> > = JSNull
> > | JSBool !Bool
> > | JSRational Bool{-as Float?-} !Rational
> > | JSString JSString
> > | JSArray [JSValue]
> > | JSObject (JSObject JSValue)
> > deriving (Show, Read, Eq, Ord, Typeable)
>
> So there are six different ways to construct a JSValue, the last one
> is the JSObject constructor. It contains one item which is of *type*
> JSObject JSValue. This time, JSObject refers to a datatype, also
> defined in the library:
>
> > newtype JSObject e = JSONObject { fromJSObject :: [(String, e)] }
> > deriving (Eq, Ord, Show, Read, Typeable )
>
> Now to your functions: if you write
>
> > getObject :: JSValue -> JSObject JSValue
> > getObject x@(JSObject _) = x
>
> or
>
> > getObject :: JSValue -> JSObject JSValue
> > getObject (JSObject x) = JSObject x
>
> you are writing essentially the identity function, but trying to
> assign a more specific type to the value. This doesn't quite work in
> Haskell. There's no subtyping between different datatypes.
>
> Instead, what you should do is perform the pattern match once and
> extract its contents:
>
> > getObject :: JSValue -> JSObject JSValue
> > getObject (JSObject x) = x
>
> Now you have the stuff that was "inside" the constructor, and isolated
> the point of failure.
>
> Cheers,
> Andres
>
I'm sorry, but I copied exact code and I'm still getting an error:
$:l tst.hs
[1 of 1] Compiling Main ( tst.hs, interpreted )
Ok, modules loaded: Main.
$let a = toJSObject [("A","a")]
$a
JSONObject {fromJSObject = [("A","a")]}
$encode a
"{\"A\":\"a\"}"
$getJSObj a
<interactive>:428:10:
Couldn't match expected type `JSValue'
with actual type `JSObject [Char]'
In the first argument of `getJSObj', namely `a'
In the expression: getJSObj a
In an equation for `it': it = getJSObj a
$
------------------------------
Message: 2
Date: Wed, 27 Mar 2013 07:16:53 +0100
From: Miro Karpis <[email protected]>
Subject: [Haskell-beginners] cabal install local troubles (osx)
To: [email protected]
Message-ID:
<CAJnnbxFf4bdDX=eeorfpfs9tkw4dlufyrenn_-sv-nzyrok...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
please, can you help me with following. I have installed haskell on mac
from the package. When I check cabal -V I can see 1.14.0
That is because the cabal is loading from /Library/Haskell/bin.
After that I run 'cabal install cabal-install', I get following output:
Installing executable(s) in
/Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin
Updating documentation index /Users/miro/Library/Haskell/doc/index.html
So the new version of cabal is installed in another place. When I install
new package via cabal, it uses the 1.14.0 version. I have tried to copy the
new 1.16.0.2 version to bin, but that just didn't help because the new
packages have been installed somewhere else.
Please what is the proper way to fix this?
many thanks,
miro
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130327/20663285/attachment-0001.htm>
------------------------------
Message: 3
Date: Wed, 27 Mar 2013 07:44:12 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] cabal install local troubles (osx)
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<CAC42Re=3gU=2SNZjPevQ1GOYzoFRv=cpwn5ys2byyu4qvql...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hello,
On linux and windows I add this folder to the path and then it works:
$HOME/.cabal/bin
emmanuel
On Wed, Mar 27, 2013 at 7:16 AM, Miro Karpis <[email protected]>wrote:
> please, can you help me with following. I have installed haskell on mac
> from the package. When I check cabal -V I can see 1.14.0
> That is because the cabal is loading from /Library/Haskell/bin.
>
> After that I run 'cabal install cabal-install', I get following output:
>
> Installing executable(s) in
> /Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin
> Updating documentation index /Users/miro/Library/Haskell/doc/index.html
>
> So the new version of cabal is installed in another place. When I install
> new package via cabal, it uses the 1.14.0 version. I have tried to copy the
> new 1.16.0.2 version to bin, but that just didn't help because the new
> packages have been installed somewhere else.
>
> Please what is the proper way to fix this?
>
> many thanks,
> miro
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130327/61bfb3e6/attachment-0001.htm>
------------------------------
Message: 4
Date: Wed, 27 Mar 2013 07:49:17 +0100
From: Miro Karpis <[email protected]>
Subject: Re: [Haskell-beginners] cabal install local troubles (osx)
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<CAJnnbxG+jU5-8rYn82=A6wzfvLhQvyyKU=g3K+sj6CE=xi_...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
many thanks, but this is my output:
mac-2:~ miro$ cd $HOME/.cabal/bin
-bash: cd: /Users/miro/.cabal/bin: No such file or directory
mac-2:~ miro$
cheers,
m.
On Wed, Mar 27, 2013 at 7:44 AM, Emmanuel Touzery <[email protected]>wrote:
> Hello,
>
> On linux and windows I add this folder to the path and then it works:
> $HOME/.cabal/bin
>
> emmanuel
>
>
> On Wed, Mar 27, 2013 at 7:16 AM, Miro Karpis <[email protected]>wrote:
>
>> please, can you help me with following. I have installed haskell on mac
>> from the package. When I check cabal -V I can see 1.14.0
>> That is because the cabal is loading from /Library/Haskell/bin.
>>
>> After that I run 'cabal install cabal-install', I get following output:
>>
>> Installing executable(s) in
>> /Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin
>> Updating documentation index /Users/miro/Library/Haskell/doc/index.html
>>
>> So the new version of cabal is installed in another place. When I install
>> new package via cabal, it uses the 1.14.0 version. I have tried to copy the
>> new 1.16.0.2 version to bin, but that just didn't help because the new
>> packages have been installed somewhere else.
>>
>> Please what is the proper way to fix this?
>>
>> many thanks,
>> miro
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130327/01a532fc/attachment-0001.htm>
------------------------------
Message: 5
Date: Wed, 27 Mar 2013 09:22:27 +0100
From: Daniel Trstenjak <[email protected]>
Subject: Re: [Haskell-beginners] "downcasting"
To: [email protected]
Message-ID: <20130327082227.GA2370@machine>
Content-Type: text/plain; charset=us-ascii
Hi Jamie,
> I'm sorry, but I copied exact code and I'm still getting an error:
>
> $:l tst.hs
> [1 of 1] Compiling Main ( tst.hs, interpreted )
> Ok, modules loaded: Main.
> $let a = toJSObject [("A","a")]
> $a
> JSONObject {fromJSObject = [("A","a")]}
> $encode a
> "{\"A\":\"a\"}"
> $getJSObj a
>
> <interactive>:428:10:
> Couldn't match expected type `JSValue'
> with actual type `JSObject [Char]'
> In the first argument of `getJSObj', namely `a'
> In the expression: getJSObj a
> In an equation for `it': it = getJSObj a
> $
'getJSObj' seems to extract a JSObject from a JSValue, but
you are giving a JSObject to 'getJSObj'.
Try this:
getJSObj $ JSValue a
Greetings,
Daniel
------------------------------
Message: 6
Date: Wed, 27 Mar 2013 10:39:34 +0100
From: Miro Karpis <[email protected]>
Subject: Re: [Haskell-beginners] cabal install local troubles (osx)
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<cajnnbxgf+qvvqv1gs8w8yhsepdo3aanonivdrneofpobttb...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I did a bit more checking and I can see in ~/.cabal only config.platform
and config files. No bin folder.
I just did a fresh haskell package install. After that I run:
mac-2:.cabal miro$ cabal -V
*cabal-install version 0.14.0*
using version 1.14.0 of the Cabal library
mac-2:.cabal miro$ cabal update
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
mac-2:.cabal miro$ cabal install cabal-install
Resolving dependencies...
...
...
...
Installing executable(s) in
*/Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin*
Updating documentation index /Users/miro/Library/Haskell/doc/index.html
mac-2:.cabal miro$ cabal -V
*cabal-install version 0.14.0*
*
*
*
*
mac-2:.cabal miro$ ls ~/.cabal
config config.platform
mac-2:bin miro$ cd /Library/Haskell/bin
mac-2:bin miro$ ls -l
total 5712
lrwxr-xr-x 1 miro wheel 26 Mar 27 10:17 alex ->
../lib/alex-3.0.2/bin/alex
lrwxr-xr-x 1 miro wheel 10 Mar 27 10:17 cabal -> cabal.wrap
lrwxr-xr-x 1 miro wheel 37 Mar 27 10:17 *cabal.real ->
../lib/cabal-install-0.14.0/bin/cabal*
-rwxr-xr-x 1 root admin 4328 Nov 5 03:44 cabal.wrap
lrwxr-xr-x 1 miro wheel 30 Mar 27 10:17 happy ->
../lib/happy-1.18.10/bin/happy
-rwxr-xr-x 1 root admin 1295976 Nov 5 03:44 patch-ghc-settings
-rwxr-xr-x 1 root admin 1598500 Nov 5 03:44 uninstall-hs
so it seems that the cabal update does not update the link in bin,...this
should be working, or? Do I need to always update the link after each new
version of cabal?
m.
On Wed, Mar 27, 2013 at 7:49 AM, Miro Karpis <[email protected]>wrote:
> many thanks, but this is my output:
>
> mac-2:~ miro$ cd $HOME/.cabal/bin
> -bash: cd: /Users/miro/.cabal/bin: No such file or directory
> mac-2:~ miro$
>
> cheers,
> m.
>
> On Wed, Mar 27, 2013 at 7:44 AM, Emmanuel Touzery <[email protected]>wrote:
>
>> Hello,
>>
>> On linux and windows I add this folder to the path and then it works:
>> $HOME/.cabal/bin
>>
>> emmanuel
>>
>>
>> On Wed, Mar 27, 2013 at 7:16 AM, Miro Karpis
>> <[email protected]>wrote:
>>
>>> please, can you help me with following. I have installed haskell on mac
>>> from the package. When I check cabal -V I can see 1.14.0
>>> That is because the cabal is loading from /Library/Haskell/bin.
>>>
>>> After that I run 'cabal install cabal-install', I get following output:
>>>
>>> Installing executable(s) in
>>> /Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin
>>> Updating documentation index /Users/miro/Library/Haskell/doc/index.html
>>>
>>> So the new version of cabal is installed in another place. When I
>>> install new package via cabal, it uses the 1.14.0 version. I have tried to
>>> copy the new 1.16.0.2 version to bin, but that just didn't help because the
>>> new packages have been installed somewhere else.
>>>
>>> Please what is the proper way to fix this?
>>>
>>> many thanks,
>>> miro
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130327/be566c20/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 57, Issue 37
*****************************************