The Haskell Guide
Confusing type and value
Initializing search
    GitHub
    • Home
    • Getting Started
    • Basics
    • Thinking in Haskell
    • Typeclasses
    • Laziness
    • Libraries
    • Case Study
    • Gotchas
    • FAQs
    • Resources
    GitHub
    • Home
      • Quick start
      • Example Haskell File
      • Configuration
      • Values and Types
      • Creating types
      • Functions
      • Syntactic constructs
      • Type Checking
      • Type Inference
      • Purity
      • Immutability
      • Thinking functionally
      • Typeclasses
      • Important typeclasses
      • Laziness
      • How to use libraries
      • Overview of the ecosystem
      • Dictionaries and sets
      • Property-based testing
      • JSON
      • Side-Effects
      • Parsing
      • Lenses
      • Overview
      • Chess Logic
      • Parsing
      • Evaluator
      • REPL
      • Tests
      • Lists
      • Punning
      • Strings
      • Show value
      • Updating a variable
      • Varying output type
      • Length of tuple
      • Confusing type and value
      • Multiple Arguments
      • Optional Arguments
      • Dollar sign
      • Coercions
      • fmap with a function
      • Converting Numbers
      • Debugging
      • I/O
      • Output depends on input
      • Newtype
      • Overview
      • Articles
      • Books
      • Stack Overflow

    Confusing type and value

    Don't confuse values and types.

    For example, the type Pair

    data Pair a = P a a 
    

    takes one type parameter, a, but the value P takes two arguments of the type a.

    example :: Pair Bool
    example = P True False 
    

    The danger of confusion is exacerbated by punning.


    Last update: January 28, 2023
    Created: January 28, 2023
    Back to top
    Previous Length of tuple
    Next Multiple Arguments
    Made with Material for MkDocs