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.  question about shared data types (Ian Knopke)
   2. Re:  Segmentation fault (David Virebayre)
   3. Re:  question about shared data types (David Virebayre)
   4. Re:  question about shared data types (David Virebayre)
   5. Re:  question about shared data types (Nikita Danilenko)


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

Message: 1
Date: Mon, 29 Apr 2013 11:28:03 +0100
From: Ian Knopke <[email protected]>
Subject: [Haskell-beginners] question about shared data types
To: [email protected]
Message-ID:
        <CAC+f4wmQsiSTAxquLHEZwKPT7APUxigE4waQ4NKQ=pu8vr9...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi everyone,

I have two modules that share a common data type in their respective data
structures:

package Aaa where

      newtype Foo = Foo String

      data Bar = Bar {
          barFoo :: [Foo]
      } deriving (Show, Eq)
      ...

package Bbb where

      newtype Foo = Foo String

      data Quux = Quux {
          quuxFoo :: [Foo]
      } deriving (Show, Eq)
      ...

Both modules require the Foo newtype defined. However, in all other
respects they are separate modules that can be used independently.

Defining the newtype Foo twice, as above, throws a compilation error
(ambigious reference). Importing one module inside another breaks
independence. I've been including newtype Foo in a Common.hs module that is
included in both, as I would in C or C++. This sort of thing can easily get
more complicated as the program grows however.

I was wondering if the Haskell community has a better solution to this that
I've overlooked.


Ian Knopke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130429/82edfcc7/attachment-0001.htm>

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

Message: 2
Date: Mon, 29 Apr 2013 13:40:48 +0200
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] Segmentation fault
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cam_wfvs+uex0isz6odv8aafxs+q6tf0snf6edlpjdelertt...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

2013/4/28 Michael Peternell <[email protected]>

>
> My XCode version is 4.2 Build 4C199.
>
> I doubt that it is a hardware issue, because:
>

10 years ago we had faulty ram in our main server. Everything worked just
fine, except when compiling (using gcc) one particular program, gcc
crashed. Compiling other programs worked. Everything else worked. We were
told to try changing the rams. It worked.

It still puzzles me.

Not saying that your problem is the same, though.

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130429/9110671a/attachment-0001.htm>

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

Message: 3
Date: Mon, 29 Apr 2013 13:44:47 +0200
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] question about shared data types
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cam_wfvshwbx0pztmpp0ru1x6rryqjmm2wki5qfkcrmd7vw+...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

What about making a third module that defines and exports Foo ?

David.


2013/4/29 Ian Knopke <[email protected]>

> Hi everyone,
>
> I have two modules that share a common data type in their respective data
> structures:
>
> package Aaa where
>
>       newtype Foo = Foo String
>
>       data Bar = Bar {
>           barFoo :: [Foo]
>       } deriving (Show, Eq)
>       ...
>
> package Bbb where
>
>       newtype Foo = Foo String
>
>       data Quux = Quux {
>           quuxFoo :: [Foo]
>       } deriving (Show, Eq)
>       ...
>
> Both modules require the Foo newtype defined. However, in all other
> respects they are separate modules that can be used independently.
>
> Defining the newtype Foo twice, as above, throws a compilation error
> (ambigious reference). Importing one module inside another breaks
> independence. I've been including newtype Foo in a Common.hs module that is
> included in both, as I would in C or C++. This sort of thing can easily get
> more complicated as the program grows however.
>
> I was wondering if the Haskell community has a better solution to this
> that I've overlooked.
>
>
> Ian Knopke
>
> _______________________________________________
> 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/20130429/14065a3b/attachment-0001.htm>

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

Message: 4
Date: Mon, 29 Apr 2013 13:45:55 +0200
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] question about shared data types
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <cam_wfvvs0ogfbj40hxtlx1rznzzfi2nusrps3drenbc57n+...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

> I've been including newtype Foo in a Common.hs module that is included in
both

Ah, you alredy did that, I didn't see it. Sorry for the noise.



2013/4/29 David Virebayre <[email protected]>

> What about making a third module that defines and exports Foo ?
>
> David.
>
>
> 2013/4/29 Ian Knopke <[email protected]>
>
>> Hi everyone,
>>
>> I have two modules that share a common data type in their respective data
>> structures:
>>
>> package Aaa where
>>
>>       newtype Foo = Foo String
>>
>>       data Bar = Bar {
>>           barFoo :: [Foo]
>>       } deriving (Show, Eq)
>>       ...
>>
>> package Bbb where
>>
>>       newtype Foo = Foo String
>>
>>       data Quux = Quux {
>>           quuxFoo :: [Foo]
>>       } deriving (Show, Eq)
>>       ...
>>
>> Both modules require the Foo newtype defined. However, in all other
>> respects they are separate modules that can be used independently.
>>
>> Defining the newtype Foo twice, as above, throws a compilation error
>> (ambigious reference). Importing one module inside another breaks
>> independence. I've been including newtype Foo in a Common.hs module that is
>> included in both, as I would in C or C++. This sort of thing can easily get
>> more complicated as the program grows however.
>>
>> I was wondering if the Haskell community has a better solution to this
>> that I've overlooked.
>>
>>
>> Ian Knopke
>>
>> _______________________________________________
>> 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/20130429/77a33b43/attachment-0001.htm>

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

Message: 5
Date: Mon, 29 Apr 2013 13:47:10 +0200
From: Nikita Danilenko <[email protected]>
Subject: Re: [Haskell-beginners] question about shared data types
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Hi, Ian,

you can use qualified imports to manage that. Then you can write

> module Test where
>
> import qualified Aaa as QualifiedA ( Foo )
>
> import Bbb                         ( Foo )

Below you can use barFoo by prepending QualifiedA e.g.

> fooA = QualifiedA.Foo "Hi, I'm from A"
> fooB = Foo "I belong to B"

More information is available at

http://www.haskell.org/haskellwiki/Import

Regards,

Nikita


On 29/04/13 12:28, Ian Knopke wrote:
> Hi everyone,
>
> I have two modules that share a common data type in their respective
> data structures:
>
> package Aaa where
>
>       newtype Foo = Foo String
>
>       data Bar = Bar {
>           barFoo :: [Foo]
>       } deriving (Show, Eq)
>       ...
>
> package Bbb where
>
>       newtype Foo = Foo String
>
>       data Quux = Quux {
>           quuxFoo :: [Foo]
>       } deriving (Show, Eq)
>       ...
>
> Both modules require the Foo newtype defined. However, in all other
> respects they are separate modules that can be used independently.
>
> Defining the newtype Foo twice, as above, throws a compilation error
> (ambigious reference). Importing one module inside another breaks
> independence. I've been including newtype Foo in a Common.hs module
> that is included in both, as I would in C or C++. This sort of thing
> can easily get more complicated as the program grows however.
>
> I was wondering if the Haskell community has a better solution to this
> that I've overlooked.
>
>
> Ian Knopke
>
>
> _______________________________________________
> 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/20130429/cf02256a/attachment.htm>

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

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


End of Beginners Digest, Vol 58, Issue 46
*****************************************

Reply via email to