Hi Guillaume,
I'm still a newbie to Idris (1 month), but I'll say how I see it...
If you change either one of the False to True then take terminates, but xs has not been fully evaluated. It can't be. If 'take' were truly strict xs should not type check because there is an 'Inf' there - it may not be possible to fully evaluate it, by definition of strict. So it may be strict up to a 'delay' or something, and that's the problem. It shouldn't type check like that. It should say "I can't prove this isn't an infinite list and as such I can't be sure to evaluate it". In other words there is a type error!
A LazyList catches the problem because a LazyList surprisingly is finite. But of course you want to be able, pragmatically and also theoretically, to apply 'take' to infinite lists (eg streams). That's crucial. BUT...how? There is a right way IMHO...
'take' should require a proof of sufficient productivity for take to terminate, where an 'external input' would suffice as a proof - I mean, waiting for input isn't quite the same as hanging! The logical responsibility for productivity passes to the external system (eg user input). A pragma based on a 'believe me' should be available to bypass that consideration so that if you aren't proving things about infinite lists you don't need to bother with any of this:Â
%parse inf onÂ
If you want to have to provide a proof that 'take' will terminate (as I do!) that should require some more work. But it should be either the default, or again, activated by a pragma:
%parse inf off
or
%productivity onÂ
...or some such.
See what I mean?
Robert
On Wed, Jan 20, 2021 at 3:03 PM guillaume allais <guillaum...@ens-lyon.org> wrote:
Hi Robert,
Isn't `take` strict in its list argument?
You may want to use the library-provided LazyList type instead of List.
Best,
On 16/01/2021 21:02, Robert Watson wrote:
CAUTION: This email originated outside the University. Check before clicking links or attachments.
--
You received this message because you are subscribed to the Google Groups "Idris Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idris-lang/457d734d-519c-41cc-a779-921dae60dc4fn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idris-lang/c7799c7b-7633-47ba-811c-3bbf6fb050ban%40googlegroups.com.
CAUTION: This email originated outside the University. Check before clicking links or attachments. Hi all Sorry for jumping into this discussion. Guillaume, we already have `Data.List.Lazy` in contrib. Could you please quickly explain what the difference is between that one (which, if I understand correctly, could also be potentially infinite) and your `Colist` data type? The only difference is the use of `Inf` vs `Lazy` and I never really understood this distinction. Thanks Stefan On Fri, Jan 22, 2021 at 03:26:46PM +0000, guillaume allais wrote:
Streams seem to work well, even though they use Inf in their definition. I think the problem (only my current understanding) is that Inf is unsafe, even though Streams are not (as far as I have tested their edge cases). The way I see it it matters where Inf is used in terms of future verification of Idris. The deeper the definition of Stream is placed - say for example as a builtin (just the core 'data' declaration, not the rest of the functions), the easier it might be to verify stuff later...just a thought. Inf might then be allowed or disallowed more easily via pragmas. (The data structure I was imagining in my email to you Guillaume I now think I can easily write myself using an Either structure that captures both (finite) LazyList and (infinite) Stream.) Robert On Wednesday, January 20, 2021 at 9:18:29 PM UTC+1 gallais wrote: Oh, I see, my bad: you're using these lists as it they were coinductive. But they're not. A `List` in Idris is necessarily finite unlike in Haskell for instance. The definition of `testList` is perverse enough to trick Idris but it should be illegal. If you want potentially infinite lists you should define a separate type of colists in a style analogous to Stream: defined in Prelude.Types https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidris-lang%2FIdris2%2Fblob%2Fmaster%2Flibs%2Fprelude%2FPrelude%2FTypes.idr%23L388&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159253428%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JDw1vGe5A3Lpt%2Ba8jar9WBbANn5HYIi0lKlqpOp0%2BMY%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidris-lang%2FIdris2%2Fblob%2Fmaster%2Flibs%2Fprelude%2FPrelude%2FTypes.idr%23L388&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NtyBLUtN2MO3X4xOEEEVT6NEPgi38K2G%2B735eZwK4oI%3D&reserved=0> and with library code in Data.Stream https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidris-lang%2FIdris2%2Fblob%2Fmaster%2Flibs%2Fbase%2FData%2FStream.idr&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9s0xHR3B3qG%2BV6%2B%2Frtcsb%2F%2BrRNLXMRqUUdguh7Fdpco%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidris-lang%2FIdris2%2Fblob%2Fmaster%2Flibs%2Fbase%2FData%2FStream.idr&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9s0xHR3B3qG%2BV6%2B%2Frtcsb%2F%2BrRNLXMRqUUdguh7Fdpco%3D&reserved=0>
. To view this discussion on the web visit https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2F457d734d-519c-41cc-a779-921dae60dc4fn%2540googlegroups.com&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yoD8IpntwmuLovZT0DEoahfg%2FKm61vxipy3T0S7p3aw%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2F457d734d-519c-41cc-a779-921dae60dc4fn%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1JUVfSK3MPbLqW1XyqgnHHEY6lFBVxF5ZrXN4WAbO88%3D&reserved=0>.
-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com <mailto:idris-lang+...@googlegroups.com>
. To view this discussion on the web visit https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2Fc7799c7b-7633-47ba-811c-3bbf6fb050ban%2540googlegroups.com&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=T1h9SACvMaXIsyekkzVkT0zN3W2VLJSvWbNwKFeyc6Y%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2Fc7799c7b-7633-47ba-811c-3bbf6fb050ban%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fpbfilxBJ0O6BeA6UldLJG3fnjSEadXck6kaFsMUykU%3D&reserved=0>.
-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com
-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com
This shouldn't get through the type checker (but it does for me)...something's up: (entering 'testcode' hangs in the REPL) booleanpred: Nat -> Bool booleanpred Z = False booleanpred (S k) = False total testList : Inf (List Nat) testList = Z :: (map S testList) total testList2 : Inf (List Nat) testList2 = filter booleanpred testList total oneornot : Inf (List Nat) -> Nat oneornot xs = length (take 1 xs) total testcode : Nat testcode = oneornot testList2 --oneornot testList2/ testcode --causes problems when entered in REPL --NON PRODUCTIVE/NON-TERMINATING CODE -- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com
. To view this discussion on the web visit https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2F457d734d-519c-41cc-a779-921dae60dc4fn%2540googlegroups.com&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yoD8IpntwmuLovZT0DEoahfg%2FKm61vxipy3T0S7p3aw%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2F457d734d-519c-41cc-a779-921dae60dc4fn%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1JUVfSK3MPbLqW1XyqgnHHEY6lFBVxF5ZrXN4WAbO88%3D&reserved=0>.-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com <mailto:idris-lang+...@googlegroups.com>. To view this discussion on the web visit https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2Fc7799c7b-7633-47ba-811c-3bbf6fb050ban%2540googlegroups.com&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=T1h9SACvMaXIsyekkzVkT0zN3W2VLJSvWbNwKFeyc6Y%3D&reserved=0 <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fidris-lang%2Fc7799c7b-7633-47ba-811c-3bbf6fb050ban%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7Cguillaume.allais%40strath.ac.uk%7C9a13f82e44ae4dbe234808d8beeb5023%7C631e0763153347eba5cd0457bee5944e%7C0%7C0%7C637469265159263422%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fpbfilxBJ0O6BeA6UldLJG3fnjSEadXck6kaFsMUykU%3D&reserved=0>.
-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com-- You received this message because you are subscribed to the Google Groups "Idris Programming Language" group. To unsubscribe from this group and stop receiving emails from it, send an email to idris-lang+...@googlegroups.com
I've basically got Colists done by the way, though I need help with Namespaces for turning it into 'style guide' library code. Will send it to Gillaume to look at soon. I came across something frustrating though: the 'where' block seems to suffer from limited functionality. Is this correct behaviour?
The following code complains about the last line in the where block,
but if I use helper function iducIndex to do the same thing instead
(and comment out the ‘where’ block) it does not. Is there a
reason for this? Or is ‘where’ not behaving as expected as I personally feel?
To view this discussion on the web visit https://groups.google.com/d/msgid/idris-lang/990291fd-c56d-4436-bb9c-3da71ea32efen%40googlegroups.com.