[Haskell-cafe] FP design
Jules Bean
jules at jellybean.co.uk
Tue Nov 6 10:59:35 EST 2007
Levi Stephen wrote:
> Hi,
>
> I'm was wondering how most people work during when designing a
> functional program. Do you create data structures/types first? Do you
> work from some type signatures?
>
> For example, take a blog. Is the first step likely to be something like:
>
> data BlogEntry = BlogEntry {
> title::String,content::String,comments::[Comment] }
> type Blog = [BlogEntry]
>
> or more likely thinking about what functions will be required:
>
> addEntry :: BlogEntry -> Blog -> Blog
> displayBlog :: Blog -> HTML
> displayEntry :: BlogEntry -> HTML
I think you can work either way around, or both, or a mixture.
If I had to choose between the two, I would *definitely* choose the
second. Writing a program is like defining a custom language. Start by
defining your primitives (functions). The data types are just "whatever
you need to make it work".
YMMV :)
Jules
More information about the Haskell-Cafe
mailing list