view patterns

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

view patterns

Cetin Sert
let has [] = False; has _ = True

-- this one is ok

let empty list = case has list of True -> False; False -> True

-- the following is problematic
let emp (has -> True) = False; emp (has -> False) = True

<interactive>:1:4:
    Warning: Pattern match(es) are overlapped
             In the definition of `emp':
                 emp ((has -> True)) = ...
                 emp ((has -> False)) = ...

Why do I get this error in ghc or when I try to compile a file with view patterns?
(using -fglasgow-exts  and -XViewPatterns, ghc 6.10.1)

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: view patterns

Bulat Ziganshin-2
Hello Cetin,

Wednesday, November 5, 2008, 8:34:14 AM, you wrote:

>  let emp (has -> True) = False; emp (has -> False) = True

>      Warning: Pattern match(es) are overlapped

proibably it's because GHC can't check view patterns for overlaps?

--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: view patterns

Cale Gibbard
In reply to this post by Cetin Sert
2008/11/5 Cetin Sert <[hidden email]>:
> <interactive>:1:4:
>     Warning: Pattern match(es) are overlapped
>              In the definition of `emp':
>                  emp ((has -> True)) = ...
>                  emp ((has -> False)) = ...
>
> Why do I get this error in ghc or when I try to compile a file with view
> patterns?
> (using -fglasgow-exts  and -XViewPatterns, ghc 6.10.1)

This is a bug which appears to be known about:
http://hackage.haskell.org/trac/ghc/ticket/2395

 - Cale
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: view patterns

Dan Licata
Hi everyone,

Yes, the current overlap checker thinks all view patterns are
overlapped.  The pattern overlap/exhaustiveness checker needs to be
rewritten to account for GADTs and view patterns.

You can use -fno-warn-overlapping-patterns to suppress these warning
(along with any actual overlaps, though, unfortunately).

-Dan

On Nov05, Cale Gibbard wrote:

> 2008/11/5 Cetin Sert <[hidden email]>:
> > <interactive>:1:4:
> >     Warning: Pattern match(es) are overlapped
> >              In the definition of `emp':
> >                  emp ((has -> True)) = ...
> >                  emp ((has -> False)) = ...
> >
> > Why do I get this error in ghc or when I try to compile a file with view
> > patterns?
> > (using -fglasgow-exts  and -XViewPatterns, ghc 6.10.1)
>
> This is a bug which appears to be known about:
> http://hackage.haskell.org/trac/ghc/ticket/2395
>
>  - Cale
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe