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 5946033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:55+00:00 2026-05-22T16:45:55+00:00

the code below produces a non-exhaustive pattern in function asd data Token = TokenPlus

  • 0

the code below produces a “non-exhaustive pattern in function asd”

data Token = TokenPlus
            | TokenMinus
            | TokenMal
            | TokenGeteilt
            | TokenKlammerAuf
            | TokenKlammerZu
            | TokenInt Int
            deriving(Eq,Show)
asd (x:xs) = if x == '+' then (x, TokenPlus): (asd xs)
             else (x, TokenInt 1): (asd xs)

Let’s say i wanted to catch this kind of error, i would use catch (asd "my_string") my_handler_function. Fine until here, but what Type is ":t 'non-exhaustive pattern' " made of ?

  • 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-22T16:45:56+00:00Added an answer on May 22, 2026 at 4:45 pm

    Pattern match failure exceptions are of type PatternMatchFail. The base exceptions are all defined in Control.Exception.

    Below is a use of Control.Exception.catch to catch a pattern match failure of the type you’re talking about. Here, my operation and handler are both of type IO (), but you
    can make it anything you want – if the operatio is IO Int then the exception handler could return a default IO Int.

    {-# LANGUAGE ScopedTypeVariables #-}
    import Control.Exception as X
    
    func = X.catch (print $ asd []) printErr
    
    printErr :: SomeException -> IO ()
    printErr e =  do
            case fromException e of
                    Just (x:: PatternMatchFail) -> putStrLn "I caught the exception"
                                                >> print x
                    nothing -> return ()
    
    asd :: [Int] -> [Int]
    asd (x:xs) = xs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below produces a NumberFormatException in this line: val cache = cf.createCache(Collections.emptyMap()) Do
Given the code below, how would you create/implement SR.h so that it produces the
The code below produces this output fine: This is page one. This is page
The below code produces output consisting of two green items. Between those items there
See below 2 versions of code and SQL it produces. I want to load
Code below produces button and icon: Button and input box are not in same
My code below produces an error, unknown modified |... I'm trying to use it
the code below produces compiler error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'
Hello all i have the code below which produces four wheels each with the
Below code produces two smiley faces when I call case 2 after case 1

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.