-
Notifications
You must be signed in to change notification settings - Fork 27
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
Chapter 4 Polymorphism #130
Comments
Did you put specifications in your code? ~~~~~{.spec}
loop :: lo:Nat -> hi:{Nat|lo <= hi} -> a -> (Btwn lo hi -> a -> a) -> a
~~~~~ |
I thought it would be automatically inferred though. Maybe I misunderstood
the text.
…On Thu, Sep 5, 2024 at 07:34 Samuel ***@***.***> wrote:
Did you put specifications in your code?
~~~~~{.spec}loop :: lo:Nat -> hi:{Nat|lo <= hi} -> a -> (Btwn lo hi -> a -> a) -> a~~~~~
—
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSIB3SNPJMG6HTZXUGRNPTZU7UP3AVCNFSM6AAAAABNUKEHXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZQGYZTSMRXGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
How it going now? |
Yeah! With the annotation it works.
…On Fri, Sep 6, 2024 at 09:30 Samuel ***@***.***> wrote:
How it going now?
—
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABSIB3SARRY4MA5ZAHHH47LZVFKZXAVCNFSM6AAAAABNUKEHXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZTGQZDMMBVG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! I am trying to go through the tutorial. But I think type inference is not working at.
`{-@ LIQUID "--no-termination" @-}
module DemoLib where
import Data.Vector
loop :: Int -> Int -> a -> (Int -> a -> a) -> a
loop lo hi base f = go base lo
where
go acc i
| i < hi = go (f i acc) (i + 1)
| otherwise = acc
vectorSum' :: Vector Int -> Int
vectorSum' vec = loop 0 n 0 body
where
body i acc = acc + (vec ! i)
n = Data.Vector.length vec
`
It is failing with
`
**** LIQUID: UNSAFE ************************************************************
app/DemoLib.hs:20:31: error:
Liquid Type Mismatch
.
The inferred type
VV : {v : GHC.Types.Int | v == i##a17O}
.
is not a subtype of the required type
VV : {VV##694 : GHC.Types.Int | VV##694 < vlen vec##a17L}
.
in the context
i##a17O : GHC.Types.Int
|
20 | body i acc = acc + (vec ! i)`
The text was updated successfully, but these errors were encountered: