Skip to content

Instantly share code, notes, and snippets.

@rybla
Created January 7, 2021 03:20
Show Gist options
  • Save rybla/833e773031d6eff867403ac01b945471 to your computer and use it in GitHub Desktop.
Save rybla/833e773031d6eff867403ac01b945471 to your computer and use it in GitHub Desktop.
[Liquid Haskell] Problem with naming record fields for List data type.
module ListFailure where
import Prelude hiding ( head
, tail
)
{-@
data List a = Nil | Cons { head :: a , tail :: List a }
@-}
data List a = Nil | Cons { head :: a , tail :: List a }
{-
This file failes to compile with:
> liquid ListFailure.hs
Yields this error:
10 | data List a = Nil | Cons { head :: a , tail :: List a }
^^^^^
ListFailure.head :: forall a .
lq$recSel:(ListFailure.List a) -> {VV : a | VV == head lq$recSel}
Sort Error in Refinement: {VV : a##xo | VV == head lq$recSel}
Cannot unify fix$36$$91$$93$ with ListFailure.List in expression: head lq$recSel
/Users/henry/Documents/Prototypes/liquidhaskell/list-fields-bug/ListFailure.hs:12:21-55: Error: Illegal type specification for `ListFailure.Cons`
12 | data List a = Nil | Cons { head :: a , tail :: List a }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ListFailure.Cons :: forall a .
head:a -> tail:(ListFailure.List a) -> {VV : (ListFailure.List a) | tail VV == tail
&& head VV == head}
Sort Error in Refinement: {VV : (ListFailure.List a##agi) | (tail VV == tail##ListFailure.Cons
&& head VV == head##ListFailure.Cons)}
Cannot unify fix$36$$91$$93$ with ListFailure.List in expression: tail VV
Using: LiquidHaskell Version 0.8.6.0.
-}
module ListSuccess where
import Prelude hiding ( head
, tail
)
{-@
data List a = Nil | Cons { lh :: a , lt :: List a }
@-}
data List a = Nil |Cons { lh :: a , lt :: List a }
{-
This file complies successfully with:
> liquid ListSuccess.hs
Using: LiquidHaskell Version 0.8.6.0.
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment