Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying data type with wrong number of abstract refinement params could give better errors #297

Open
csgordon opened this issue Jan 4, 2015 · 0 comments

Comments

@csgordon
Copy link

csgordon commented Jan 4, 2015

module Arity where

{-@ data T a <p :: a -> Prop, q :: a -> Prop > = MkT (t_x :: a) @-}
data T a = MkT a

-- error spec 1
{- f :: forall <p :: a -> Prop, q :: a -> Prop>. T <p> a -> a @-}
-- error spec 2
{- f :: forall <p :: a -> Prop, q :: a -> Prop>. T <p, q, {\ y -> (true)}> a -> a @-}
f :: T a -> a
f (MkT x) = x

The first spec, if used, produces:

LiquidHaskell Copyright 2009-14 Regents of the University of California. All Rights Reserved.

liquid: 
**** ERROR *********************************************************************
**** ERROR *********************************************************************
**** ERROR *********************************************************************
safeZipWith called on non-eq-sized lists (nxs = 2, nys = 1) : appRefts: Arity.T
**** ERROR *********************************************************************
**** ERROR *********************************************************************
**** ERROR *********************************************************************

This at least contains enough information to figure out it's a misapplication of Arity.T, but requires manually inspecting everywhere you wrote a LH spec using T.

The second spec's error is less helpful:

LiquidHaskell Copyright 2009-14 Regents of the University of California. All Rights Reserved.

liquid: 
**** ERROR *********************************************************************
**** ERROR *********************************************************************
**** ERROR *********************************************************************
YUCKER
**** ERROR *********************************************************************
**** ERROR *********************************************************************
**** ERROR *********************************************************************

This one also requires looking at all uses of T in LH specs, but I figured this out purely by luck. Curiously, if you replace the lambda in that spec with another use of p or q, the file type-checks despite the bad type application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants