Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1.  hierarchy of modules (Michael Mossey)
   2. Re:  hierarchy of modules (Daniel Fischer)
   3.  Class definition syntax (Shawn Willden)
   4. Re:  Class definition syntax (Joe Fredette)
   5. Re:  hierarchy of modules (Steven Cummings)
   6. Re:  Class definition syntax (Daniel Fischer)
   7. Re:  hierarchy of modules (Michael Mossey)
   8. Re:  hierarchy of modules (Daniel Fischer)


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

Message: 1
Date: Sat, 31 Oct 2009 05:32:51 -0700
From: Michael Mossey <m...@alumni.caltech.edu>
Subject: [Haskell-beginners] hierarchy of modules
To: beginners@haskell.org
Message-ID: <4aec2e73.6000...@alumni.caltech.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I want to have a hierarchy of modules for a local project. Not submitting 
it to Hackage yet. I just want to refer to my local modules as

Basics.CSound
Basics.Node
Algo.Fux

etc.

how does one set this up?

Thanks,
Mike


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

Message: 2
Date: Sat, 31 Oct 2009 13:54:31 +0100
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] hierarchy of modules
To: beginners@haskell.org
Message-ID: <200910311354.31475.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="iso-8859-1"

Am Samstag 31 Oktober 2009 13:32:51 schrieb Michael Mossey:
> I want to have a hierarchy of modules for a local project. Not submitting
> it to Hackage yet. I just want to refer to my local modules as
>
> Basics.CSound
> Basics.Node
> Algo.Fux
>
> etc.
>
> how does one set this up?

Top directory: project.cabal, Setup.hs (module Main where main = defaultMain)
Subdirectry Basics:
   File CSound.hs  (module Basics.CSound (exports) where...)
   File Node.hs      (module Basics.Node (exports where...)
Subdirectory Algo:
   File Fux.hs       (module Algo.Fux (exports) where...)

cd Top directory
cabal install

>
> Thanks,
> Mike




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

Message: 3
Date: Sat, 31 Oct 2009 10:27:10 -0600
From: Shawn Willden <shawn-hask...@willden.org>
Subject: [Haskell-beginners] Class definition syntax
To: beginners@haskell.org
Message-ID: <200910311027.10559.shawn-hask...@willden.org>
Content-Type: text/plain;  charset="us-ascii"

I have a program that makes use of various data types built on top of Arrays.  
In some cases, they're data types that contain an Array plus some additonal 
information, in others, they're just "newtype" Arrays, so that I can use 
typechecking to make sure that I'm not using the wrong kind of object.

I'd really like to define an "ArrayOps" class with all of the operations I 
need, and define instances for all of the specific types.  I also use 
some "raw" Array objects, so it would be even better if I could make an 
instance of my class for Array.  And, ideally, I'd like to use the Array 
operations for my class operations.

So, I want something like:

class ArrayOps a where
    (!)    :: a -> i -> e
    (//)   :: a -> (i,e) -> a
    bounds :: a -> (i,i)
    range  :: a -> [i]

'i' and 'e' are the index and element types, respectively.

Obviously, the signatures above reference type variables that aren't declared, 
and really must be constrained to be the 'i' and 'e' that were used in 
building the type 'a' (which is an Array i e).  Something like the following 
(though this obviously doesn't work):

class ((Array.Array i e) a) => ArrayOps a where ...

I'm sure there must be a way to do this, but I can't figure out what the 
syntax would look like.

Thanks,

        Shawn.


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

Message: 4
Date: Sat, 31 Oct 2009 12:33:10 -0400
From: Joe Fredette <jfred...@gmail.com>
Subject: Re: [Haskell-beginners] Class definition syntax
To: Shawn Willden <shawn-hask...@willden.org>
Cc: beginners@haskell.org
Message-ID: <17d619c7-3d98-4190-bc9d-73575c75f...@gmail.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

You'll probably need to look at associated types/functional  
dependencies. The former is the new hotness, the latter is the old and  
not-so-busted. A quick search of the wiki ought to reveal much more  
than I can possibly explain, there is an example on the page for  
Assoc. Types about generic Map implementation, which is similar to  
what you're trying to do.



On Oct 31, 2009, at 12:27 PM, Shawn Willden wrote:

> I have a program that makes use of various data types built on top  
> of Arrays.
> In some cases, they're data types that contain an Array plus some  
> additonal
> information, in others, they're just "newtype" Arrays, so that I can  
> use
> typechecking to make sure that I'm not using the wrong kind of object.
>
> I'd really like to define an "ArrayOps" class with all of the  
> operations I
> need, and define instances for all of the specific types.  I also use
> some "raw" Array objects, so it would be even better if I could make  
> an
> instance of my class for Array.  And, ideally, I'd like to use the  
> Array
> operations for my class operations.
>
> So, I want something like:
>
> class ArrayOps a where
>    (!)    :: a -> i -> e
>    (//)   :: a -> (i,e) -> a
>    bounds :: a -> (i,i)
>    range  :: a -> [i]
>
> 'i' and 'e' are the index and element types, respectively.
>
> Obviously, the signatures above reference type variables that aren't  
> declared,
> and really must be constrained to be the 'i' and 'e' that were used in
> building the type 'a' (which is an Array i e).  Something like the  
> following
> (though this obviously doesn't work):
>
> class ((Array.Array i e) a) => ArrayOps a where ...
>
> I'm sure there must be a way to do this, but I can't figure out what  
> the
> syntax would look like.
>
> Thanks,
>
>        Shawn.
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



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

Message: 5
Date: Sat, 31 Oct 2009 11:51:29 -0500
From: Steven Cummings <estebis...@gmail.com>
Subject: Re: [Haskell-beginners] hierarchy of modules
To: beginners@haskell.org
Message-ID:
        <c1169f960910310951j2d42dd78mf00b9e493bd3f...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

What if he wanted to separately have test code? e.g. Sources and Tests each
containing identical hierarchies described above. I know cabal has an option
for source directory. It appears something  like [1] can be use to run all
tests, though I haven't yet looked into the details of how each file needs
to be structured so that all tests are detected (if, e.g., your using
quickcheck to implement your tests). Ideally, from the root directory I
would want to be able to do cabal install or cabal test.

[1] http://hackage.haskell.org/package/cabal-test

--
Steven


On Sat, Oct 31, 2009 at 7:54 AM, Daniel Fischer <daniel.is.fisc...@web.de>wrote:

> Am Samstag 31 Oktober 2009 13:32:51 schrieb Michael Mossey:
> > I want to have a hierarchy of modules for a local project. Not submitting
> > it to Hackage yet. I just want to refer to my local modules as
> >
> > Basics.CSound
> > Basics.Node
> > Algo.Fux
> >
> > etc.
> >
> > how does one set this up?
>
> Top directory: project.cabal, Setup.hs (module Main where main =
> defaultMain)
> Subdirectry Basics:
>   File CSound.hs  (module Basics.CSound (exports) where...)
>   File Node.hs      (module Basics.Node (exports where...)
> Subdirectory Algo:
>   File Fux.hs       (module Algo.Fux (exports) where...)
>
> cd Top directory
> cabal install
>
> >
> > Thanks,
> > Mike
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20091031/3f31796e/attachment-0001.html

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

Message: 6
Date: Sat, 31 Oct 2009 17:50:10 +0100
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] Class definition syntax
To: beginners@haskell.org
Message-ID: <200910311750.10712.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="iso-8859-1"

Am Samstag 31 Oktober 2009 17:33:10 schrieb Joe Fredette:
> You'll probably need to look at associated types/functional
> dependencies. The former is the new hotness, the latter is the old and
> not-so-busted. A quick search of the wiki ought to reveal much more
> than I can possibly explain, there is an example on the page for
> Assoc. Types about generic Map implementation, which is similar to
> what you're trying to do.

Or perhaps he should look at the class IArray from Data.Array.IArray, maybe he 
can just 
declare instances of IArray for his datatypes.
Without more information, I can't tell which way to go.

>
> On Oct 31, 2009, at 12:27 PM, Shawn Willden wrote:
> > I have a program that makes use of various data types built on top
> > of Arrays.
> > In some cases, they're data types that contain an Array plus some
> > additonal
> > information, in others, they're just "newtype" Arrays, so that I can
> > use
> > typechecking to make sure that I'm not using the wrong kind of object.
> >
> > I'd really like to define an "ArrayOps" class with all of the
> > operations I
> > need, and define instances for all of the specific types.  I also use
> > some "raw" Array objects, so it would be even better if I could make
> > an
> > instance of my class for Array.  And, ideally, I'd like to use the
> > Array
> > operations for my class operations.
> >
> > So, I want something like:
> >
> > class ArrayOps a where
> >    (!)    :: a -> i -> e
> >    (//)   :: a -> (i,e) -> a
> >    bounds :: a -> (i,i)
> >    range  :: a -> [i]
> >
> > 'i' and 'e' are the index and element types, respectively.
> >
> > Obviously, the signatures above reference type variables that aren't
> > declared,
> > and really must be constrained to be the 'i' and 'e' that were used in
> > building the type 'a' (which is an Array i e).  Something like the
> > following
> > (though this obviously doesn't work):
> >
> > class ((Array.Array i e) a) => ArrayOps a where ...
> >
> > I'm sure there must be a way to do this, but I can't figure out what
> > the
> > syntax would look like.
> >
> > Thanks,
> >
> >        Shawn.




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

Message: 7
Date: Sat, 31 Oct 2009 10:19:24 -0700
From: Michael Mossey <m...@alumni.caltech.edu>
Subject: Re: [Haskell-beginners] hierarchy of modules
To: beginners <beginners@haskell.org>
Message-ID: <4aec719c.3020...@alumni.caltech.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Daniel,

Thanks for the information. However, does this work for a 
test-compile-debug cycle, or for a modify-interpret cycle? These modules 
would all be in development. I don't like the idea that I have to 'cabal 
install' after any change to any module. Is that necessary?

Thanks,
Mike

Daniel Fischer wrote:
> Am Samstag 31 Oktober 2009 13:32:51 schrieb Michael Mossey:
>> I want to have a hierarchy of modules for a local project. Not submitting
>> it to Hackage yet. I just want to refer to my local modules as
>>
>> Basics.CSound
>> Basics.Node
>> Algo.Fux
>>
>> etc.
>>
>> how does one set this up?
> 
> Top directory: project.cabal, Setup.hs (module Main where main = defaultMain)
> Subdirectry Basics:
>    File CSound.hs  (module Basics.CSound (exports) where...)
>    File Node.hs      (module Basics.Node (exports where...)
> Subdirectory Algo:
>    File Fux.hs       (module Algo.Fux (exports) where...)
> 
> cd Top directory
> cabal install
> 
>> Thanks,
>> Mike
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


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

Message: 8
Date: Sat, 31 Oct 2009 19:43:20 +0100
From: Daniel Fischer <daniel.is.fisc...@web.de>
Subject: Re: [Haskell-beginners] hierarchy of modules
To: beginners@haskell.org
Message-ID: <200910311943.20529.daniel.is.fisc...@web.de>
Content-Type: text/plain;  charset="iso-8859-1"

Am Samstag 31 Oktober 2009 18:19:24 schrieb Michael Mossey:
> Hi Daniel,
>
> Thanks for the information. However, does this work for a
> test-compile-debug cycle, or for a modify-interpret cycle? These modules
> would all be in development. I don't like the idea that I have to 'cabal
> install' after any change to any module. Is that necessary?

No, that would be the step when develpment is done (for the time being).
While developing, have the same source-tree (you can add the .cabal file and 
Setup.hs 
later) and just work in ghci (compile what's not currently being worked on, so 
the code 
runs faster).

I can't guarantee that it works everywhere and with all versions of GHC, but it 
works 
here.

>
> Thanks,
> Mike
>
> Daniel Fischer wrote:
> > Am Samstag 31 Oktober 2009 13:32:51 schrieb Michael Mossey:
> >> I want to have a hierarchy of modules for a local project. Not
> >> submitting it to Hackage yet. I just want to refer to my local modules
> >> as
> >>
> >> Basics.CSound
> >> Basics.Node
> >> Algo.Fux
> >>
> >> etc.
> >>
> >> how does one set this up?
> >
> > Top directory: project.cabal, Setup.hs (module Main where main =
> > defaultMain) Subdirectry Basics:
> >    File CSound.hs  (module Basics.CSound (exports) where...)
> >    File Node.hs      (module Basics.Node (exports where...)
> > Subdirectory Algo:
> >    File Fux.hs       (module Algo.Fux (exports) where...)
> >
> > cd Top directory
> > cabal install
> >
> >> Thanks,
> >> Mike




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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 16, Issue 29
*****************************************

Reply via email to