On 11/5/07, Levi Stephen <[EMAIL PROTECTED]> 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 don't know how you can do one without the other. I would probably
start in a case like this by writing down a few basic types, then
trying to start to write down the function type signatures, which will
probably point to more types that need to be defined, iterating until
I reach a fixed point. I can't write type signatures unless I know
what the types are. But I don't know what the types should look like
unless I know what the interface should look like, either.

One thing that's for sure, though -- I always write type signatures
for top-level definitions. I can't think straight unless I write the
type signature before writing the code.

Cheers,
Tim

-- 
Tim Chevalier * catamorphism.org * Often in error, never in doubt
"Thus spake the Master Programmer: When you have learned to snatch the
error code from the trap frame, it will be time for you to leave."--J.
Geoffrey
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to