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: Functor on Tree data constructor (Gesh)
2. Re: Functor on Tree data constructor (Vlatko Basic)
3. Help installing Esqueleto (for Yesod)! (Gilberto Melfe)
4. Re: Help installing Esqueleto (for Yesod)! (David McBride)
5. Data type definition for a list of elements of alternating
types? (Jacek Dudek)
----------------------------------------------------------------------
Message: 1
Date: Wed, 02 Apr 2014 15:19:18 +0300
From: Gesh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Functor on Tree data constructor
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On April 2, 2014 2:42:39 PM GMT+03:00, Tony Morris <[email protected]> wrote:
>On 03/04/14 00:37, Gesh wrote:
>>> On 2014-04-02 12:53, Nishant wrote:
>>>> Can some explain me the error and a possibly a fix :
>>>>
>>>> data Tree a = NULL | Node (Tree a ) a (Tree a)
>>>>
>>>> instance Functor Tree where
>>>> fmap f NULL = NULL
>>>> fmap f (Node left x right) | (left == NULL) && (right == NULL)
>=
>>>> Node left (f x) right
>>>> | (left /= NULL) = Node (fmap f
>left)
>>>> x right
>>>> | (right /= NULL) = Node left x
>(fmap
>>>> f right)
>> Note that you can simplify your instance declaration to:
>>> instance Functor Tree where
>>> fmap f NULL = NULL
>>> fmap f (Node left x right) = Node (f' left) (f x) (f' right)
>>> where f' x = if x == NULL then NULL else fmap f x
>> Also note that the NULL in the then clause differs from x. Let f :: a
>-> b, then x :: Tree a and the NULL in that clause :: Tree b. These
>values are as distinct as 2 :: Int and 2.0 :: Double.
>> HTH,
>> Gesh
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>
>instance Functor Tree where
> fmap f NULL = NULL
> fmap f (Node left x right) = Node (f' left) (f x) (f' right)
> where f' = fmap f
Oops. I should have noticed my case analysis was unnecessary. Still, the
comments accompanying it are correct. NULL :: Tree a and NULL :: Tree b are
distinct values of distinct types, and therefore using one where the other is
expected will make GHC disappointed in you.
Gesh
------------------------------
Message: 2
Date: Wed, 02 Apr 2014 15:54:39 +0200
From: Vlatko Basic <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Functor on Tree data constructor
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140402/35b6078d/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 2 Apr 2014 15:56:12 +0100
From: Gilberto Melfe <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Help installing Esqueleto (for Yesod)!
Message-ID:
<cah5k6k6sznedgqtesx1yvhcbibxxqgjanaaufeczg0n1q-x...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hello community!
I'm trying to install Yesod on a freshly setup openSUSE 13.1 virtual
machine!
I installed the Haskell Platform and three other (ghc) packages required
(for yesod-bin), from the standard online repositories!
Then i issued:
cabal update
cabal install cabal-install (because cabal told me so)
export PATH=$HOME/.cabal/bin:$PATH
cabal install yesod-platform
After churning for a while, that last command stated that some packages,
more precisely the Esqueleto package, failed to install.
I tried to install it alone and got these error messages:
-- Begin Command Output
Resolving dependencies...
Configuring esqueleto-1.3.5...
Building esqueleto-1.3.5...
Preprocessing library esqueleto-1.3.5...
[1 of 4] Compiling Database.Esqueleto.Internal.PersistentImport (
src/Database/Esqueleto/Internal/PersistentImport.hs,
dist/build/Database/Esqueleto/Internal/PersistentImport.o )
[2 of 4] Compiling Database.Esqueleto.Internal.Language (
src/Database/Esqueleto/Internal/Language.hs,
dist/build/Database/Esqueleto/Internal/Language.o )
[3 of 4] Compiling Database.Esqueleto.Internal.Sql (
src/Database/Esqueleto/Internal/Sql.hs,
dist/build/Database/Esqueleto/Internal/Sql.o )
src/Database/Esqueleto/Internal/Sql.hs:531:46:
Not in scope: type constructor or class `C.ResourceT'
src/Database/Esqueleto/Internal/Sql.hs:559:42:
Not in scope: type constructor or class `C.ResourceT'
src/Database/Esqueleto/Internal/Sql.hs:619:31:
Not in scope: type constructor or class `C.ResourceT'
src/Database/Esqueleto/Internal/Sql.hs:634:24:
Not in scope: type constructor or class `C.ResourceT'
src/Database/Esqueleto/Internal/Sql.hs:636:17:
Not in scope: `C.runResourceT'
Failed to install esqueleto-1.3.5
cabal: Error: some packages failed to install:
esqueleto-1.3.5 failed during the building phase. The exception was:
ExitFailure 1
-- End Command Output
Can someone figure out what might be wrong?
(I guess it's not a dependencies issue...)
Thank You Very Much, in advance, for your time!
Gilberto
PS: Should I have included the command output in an attached file? Which
"method" is preferred?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140402/0fde2207/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 2 Apr 2014 12:00:47 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Help installing Esqueleto (for
Yesod)!
Message-ID:
<CAN+Tr408T4-KKS02eP0=T5GOW9gcO6G3EUEJb=o7d2diqe-...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Conduit was changed so that it no longer exports resourcet related types
and functions, and esqueleto is attempting to use those. It is a bug in
esqueleto, and I've registered a pull request on github here:
https://github.com/meteficha/esqueleto/pull/55
While you are waiting for that to be merged, you can pull from
https://github.com/mindreader/esqueleto.git. Just git clone it, cd into
the directory, then cabal install.
On Wed, Apr 2, 2014 at 10:56 AM, Gilberto Melfe <[email protected]>wrote:
> Hello community!
>
> I'm trying to install Yesod on a freshly setup openSUSE 13.1 virtual
> machine!
>
> I installed the Haskell Platform and three other (ghc) packages required
> (for yesod-bin), from the standard online repositories!
>
> Then i issued:
> cabal update
> cabal install cabal-install (because cabal told me so)
> export PATH=$HOME/.cabal/bin:$PATH
>
> cabal install yesod-platform
>
> After churning for a while, that last command stated that some packages,
> more precisely the Esqueleto package, failed to install.
>
> I tried to install it alone and got these error messages:
>
> -- Begin Command Output
>
> Resolving dependencies...
> Configuring esqueleto-1.3.5...
> Building esqueleto-1.3.5...
> Preprocessing library esqueleto-1.3.5...
> [1 of 4] Compiling Database.Esqueleto.Internal.PersistentImport (
> src/Database/Esqueleto/Internal/PersistentImport.hs,
> dist/build/Database/Esqueleto/Internal/PersistentImport.o )
> [2 of 4] Compiling Database.Esqueleto.Internal.Language (
> src/Database/Esqueleto/Internal/Language.hs,
> dist/build/Database/Esqueleto/Internal/Language.o )
> [3 of 4] Compiling Database.Esqueleto.Internal.Sql (
> src/Database/Esqueleto/Internal/Sql.hs,
> dist/build/Database/Esqueleto/Internal/Sql.o )
>
> src/Database/Esqueleto/Internal/Sql.hs:531:46:
> Not in scope: type constructor or class `C.ResourceT'
>
> src/Database/Esqueleto/Internal/Sql.hs:559:42:
> Not in scope: type constructor or class `C.ResourceT'
>
> src/Database/Esqueleto/Internal/Sql.hs:619:31:
> Not in scope: type constructor or class `C.ResourceT'
>
> src/Database/Esqueleto/Internal/Sql.hs:634:24:
> Not in scope: type constructor or class `C.ResourceT'
>
> src/Database/Esqueleto/Internal/Sql.hs:636:17:
> Not in scope: `C.runResourceT'
> Failed to install esqueleto-1.3.5
> cabal: Error: some packages failed to install:
> esqueleto-1.3.5 failed during the building phase. The exception was:
> ExitFailure 1
>
> -- End Command Output
>
> Can someone figure out what might be wrong?
> (I guess it's not a dependencies issue...)
>
> Thank You Very Much, in advance, for your time!
>
> Gilberto
>
> PS: Should I have included the command output in an attached file? Which
> "method" is preferred?
>
>
> _______________________________________________
> 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/20140402/eb718a72/attachment-0001.html>
------------------------------
Message: 5
Date: Wed, 2 Apr 2014 21:52:21 -0400
From: Jacek Dudek <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Data type definition for a list of
elements of alternating types?
Message-ID:
<CAJxg2_HxCTG6ORxvut0VwP=39mrpayqkdpjntguekwafx7j...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
-- As an exercise I wanted to define a datatype that is an alternating
list of elements of two different types. The best that I could do are
the type definitions below:
module BiList
( BiList (..)
, AList (EmptyA)
, BList (EmptyB)
) where
data BiList a b
= Empty
| BA (AList a b)
| BB (BList a b)
data AList a b
= EmptyA
| AL a (BList a b)
data BList a b
= EmptyB
| BL b (AList a b)
(<#) :: a -> (BList a b) -> (AList a b)
a <# bs = AL a bs
(<@) :: b -> (AList a b) -> (BList a b)
b <@ as = BL b as
infixr 5 <#
infixr 5 <@
example :: BiList Int Char
example = BA $ 1 <# 'a' <@ 2 <# 'b' <@ 3 <# 'c' <@ 4 <# 'd' <@ EmptyA
-- There are two things that I don't like about this implementation.
-- (1) The BA and BB constructors that must be applied on top of
instances of (AList a b) and (BList a b) to lift them to be of type
(BiList a b).
-- (2) Having three different constructors for an empty list: Empty,
EmptyA, EmptyB, where ideally I would just have one.
-- Is it possible to get around either of these annoyances with some
type theory gymnastics? Maybe something like the function fromIntegral
(the mechanics of which I don't really understand at this point)?
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 70, Issue 3
****************************************