Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6633947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:52:20+00:00 2026-05-25T22:52:20+00:00

While reading the QuickCheck Manual , I came across the following example: prop_RevRev xs

  • 0

While reading the QuickCheck Manual, I came across the following example:

prop_RevRev xs = reverse (reverse xs) == xs
  where types = xs::[Int]

The manual goes on to say:

Properties must have monomorphic types. `Polymorphic’ properties, such as the one above, must be restricted to a particular type to be used for testing. It is convenient to do so by stating the types of one or more arguments in a

where types = (x1 :: t1, x2 :: t2, …)

clause. Note that types is not a keyword; this is just a local declaration which provides a convenient place to restrict the types of x1, x2 etc.

I have never seen such a trick in Haskell before. Here’s what I’m really having problems with:

  1. Why does this syntax for type declarations even exist? What can it do for me that the following couldn’t?

    prop_RevRev :: [Int] -> Bool
    prop_RevRev xs = reverse (reverse xs) == xs
    
  2. Does this use of where constitute ‘special’ syntax for type declarations? Or is it consistent and logical (and if so, how?)?

  3. Is this usage standard or conventional Haskell?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:52:21+00:00Added an answer on May 25, 2026 at 10:52 pm

    where is not special syntax for type declarations. For example, this works:

    prop_RevRev :: [Int] -> Bool
    prop_RevRev xs = ys == xs
      where ys = reverse (reverse xs)
    

    and so does this:

    prop_RevRev xs = ys == xs
      where ys = reverse (reverse xs)
            ys :: [Int]
    

    The advantage of where type = (xs :: [Int]) over prop_RevRev :: [Int] -> Bool is that in the latter case you have to specify the return type, while in the former case the compiler can infer it for you. This would matter if you had a non-Boolean property, for example:

    prop_positiveSum xs = 0 < length xs && all (0 <) xs ==> 0 < sum xs
      where types = (xs :: [Int])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading Bruce Eckel i came across the following example: #include <cstdio> #include <cstdlib>
While reading a code I came across, the following definition and initialization of a
While reading Jack Shirazi's 'Java performance tuning', I came across the following statement: Instance
While reading Joe Albahari's excellent book Threading in C# I came across the following
while reading about declare construct from php manual i tried the following example using
while reading abt array_filter() from php manual,came to face example to demostrate the same
while reading from BRUCE ECKEL'S THINKING IN C++..i came across the following text In
While reading Python scripting for computational science I came across the following text in
While reading an article, I came across the following syntax: template <typename T> class
While reading http://en.wikipedia.org/wiki/C_preprocessor#Multiple_evaluation_of_side_effects , I came across this example: \#define max(a,b) \ ({ typeof

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.