Last active
April 12, 2016 19:24
-
-
Save maiermic/a050505c26689fd6e874d50b7b44f297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unzip_hvect.idr:7:1-6:When checking left hand side of unzip_hvect.unzip: | |
| When checking an application of unzip_hvect.unzip: | |
| Type mismatch between | |
| HVect [] (Type of []) | |
| and | |
| HVect (zipWith (\t1 => \t2 => (t1, t2)) ts1 ts2) (Expected type) | |
| Specifically: | |
| Type mismatch between | |
| [] | |
| and | |
| zipWith (\t1 => \t2 => (t1, t2)) ts1 ts2 | |
| Holes: unzip_hvect.unzip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module zip_hvect | |
| import Data.Vect | |
| import Data.HVect | |
| unzip : {ts1, ts2 : Vect n Type} -> HVect (zipWith (\t1,t2 => the Type (t1, t2)) ts1 ts2) -> (HVect ts1, HVect ts2) | |
| unzip [] = ([], []) | |
| unzip ((l, r)::xs) with (unzip xs) | |
| | (lefts, rights) = (l::lefts, r::rights) |
Author
It passes the type check and compiles, but
zip_hvect.unzip [(1, 2)]
results in an error
(input):1:17:When checking an application of function zip_hvect.unzip:
Type mismatch between
HVect [(Integer, Integer)] (Type of [(1, 2)])
and
HVect (zipWith (\t1 => \t2 => (t1, t2)) ts1 ts2) (Expected type)
Specifically:
Type mismatch between
[(Integer, Integer)]
and
zipWith (\t1 => \t2 => (t1, t2)) ts1 ts2
I would expect
([1], [2]) : (HVect [Integer], HVect [Integer])
The type checker won't run the computation backwards for you here. But you can provide it with the necessary info:
λΠ> zip_hvect.unzip (the (HVect (zipWith (\x,y=>(x,y)) [Int] [Nat])) [(1,2)])
([1], [2]) : (HVect [Int], HVect [Nat])
Author
What causes this issue?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works:
So it might be a bug in dependent pattern matching here - I'd have to look closer.