Skip to content

add undefined to Prelude #44

Closed
Closed
@cdepillabout

Description

@cdepillabout

When I'm programming in Haskell, I often use undefined to get code compiling when I am just fleshing out an api/type signatues.

For instance, when doing something like authentication, I might write the following code:

type Email = String
type Password = String
data AuthInfo = AuthInfo Email Password

auth :: AuthInfo -> Boolean
auth = undefined

checkEmail :: Email -> Boolean
checkEmail email = length Email >= 7 

checkEmailAndPassword :: Email -> Password -> Boolean
checkEmailAndPassword = undefined

At first, I don't want to worry about how to write the auth and checkEmailAndPassword functions, so I leave them as undefined. After making sure the types line up and code compiles, I take out the undefined, and fill in the appropriate code.

I end up wanting undefined so often that I think it should go into the Prelude.

However, there are some downsides to putting it into the prelude:

  • It makes the Prelude slightly bigger. It seems like most people want to keep the Prelude very small.
  • It isn't type safe. I don't think the current Prelude has any functions that will blow up at runtime? Except maybe unsafeCompare and division by 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions