Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Last active March 4, 2017 15:30
Show Gist options
  • Select an option

  • Save hoelzro/e2eb3efc2f09948fce67508e09fdae55 to your computer and use it in GitHub Desktop.

Select an option

Save hoelzro/e2eb3efc2f09948fce67508e09fdae55 to your computer and use it in GitHub Desktop.
Possible Idris compiler bug
module Example
import Data.Nat.DivMod
nextBlockSize : Nat -> Nat
nextBlockSize k with (divMod k 511)
nextBlockSize (remainder + (quotient * 512)) | (MkDivMod quotient remainder remainderSmall) = ?nextBlockSize_rhs_1
-- this time with explicit "the Nat 512"
module Example
import Data.Nat.DivMod
nextBlockSize : Nat -> Nat
nextBlockSize k with (divMod k 511)
nextBlockSize (remainder + (quotient * (the Nat 512))) | (MkDivMod quotient remainder remainderSmall) = ?nextBlockSize_rhs_1
*/tmp/Example> :r
Type checking /tmp/Example.idr
/tmp/Example.idr:7:40-41:When checking left hand side of with block in Example.nextBlockSize:
When checking an application of function Prelude.Interfaces.*:
Type mismatch between
Integer (Type of 512)
and
Nat (Expected type)
Holes: Example.nextBlockSize
*/tmp/Example> :r
Type checking /tmp/Example.idr
/tmp/Example.idr:7:17:When checking left hand side of with block in Example.nextBlockSize:
Type mismatch between
remainder + quotient * 512 (Inferred value)
and
remainder + quotient * the Nat 512 (Given value)
Specifically:
Type mismatch between
plus
and
(+)
Holes: Example.nextBlockSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment