Skip to Content.
Sympa Menu

ssreflect - Re: [ssreflect] Coercing strings to seq ascii

Subject: Ssreflect Users Discussion List

List archive

Re: [ssreflect] Coercing strings to seq ascii


Chronological Thread 
  • From: Épiphanie Gédéon <>
  • To: Jason Gross <>
  • Cc:
  • Subject: Re: [ssreflect] Coercing strings to seq ascii
  • Date: Fri, 16 Feb 2018 17:43:03 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:DE8BvhW5tuV84tV63LXnEemfB0DV8LGtZVwlr6E/grcLSJyIuqrYbBeDt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZH42ycYUPAeoCM+hWoYbyqFkBogelCAa2GO/i0CVFimP40KA41ekqDAHI3BYnH9ILqHnRsM31NKYKUeC11qbIyzTDYO1L0jn88o/HbwomofaKXbltdsfe11EvFwLdjlWQs4PlOTKV2foXv2iU8eVvSPygi2khqwxqrTivw90jiojNho4P1l/E8iB5zZ8zKNalS0B7ecapHIVMuyyeLYd7QcMvT3t1tCokybAKo4O3cSsXxJg/yRPSaeaLf5WJ7x/nTuqdPyp0iXx/dL6ihRu/8U6twfDmWMauylZFtC9Fn8HMtn8T0xzT7dCKSv5n8Ueg3TaDzg7S6vtYLUwtm6rXNp0szqMqmpoctkTDGSD2mEHog6OMakok/e2o5/zmYrXguJCcK5d5hh/iPqkqgMCyAuQ1PhITU2SF+umwzqDv8E7kTLlSi/05iKjZsJTUJcQBoa65BhdY3Zg76xa+Fzem0M4XnX8GLF1bYh6HgJbmNEzQL/D/C/eymFuskDJxyPDHOr3tGInCLn/GkLv5Z7Zy91ZcyBYvzdBY/59UEaoBIOjtVU//sNzXEAM2MxCvzub8CNR905seVniVDq+YNqPSq16I6fg1L+mCfo9G8Ar6ftos/PnoxVAjnkQGNf2r1IAQbn+iGe99cm2WZHPthpEKFmJc7SQkS+m/KUWDST5aYXe/F4296rA8DsryAJ/CXoCkhr2Mmii2EpBRYEhJD1mNFTHjcIDSCKREUz6bPsI0ym9MbrOmUYJ0kEj27FarmYoiFfLd/2gjjbym0dF04+PJkhRrrG57Cs2c1yeGSGQmxzpUFQ9z57h2pAlG8nnGybJx2qUKGtla5vcPWQA/Z8aFkr5KTuvqUweERe+nDVarRtL8X2M0R9M1hsAUOwNzQoX7yB/E2CWuDvkekLnZXJE=

You're right, it worked perfectly!

I understand coercions better now, a bit like in Haskell, you can only do first-type specifications


Le 16/02/2018 à 16:50, Jason Gross a écrit :
I believe
Coercion string_to_seq : string >-> seq.
Also works.  That is, coercion signatures take the head of the type.

- Jason


On Fri, Feb 16, 2018, 8:17 AM Épiphanie Gédéon <> wrote:
Oh I did not know this notation, I thought Coercions were supposed to
have explicit types! So since I couldn't type (string >-> (seq ascii)),
I thought wrappers were mandatory for it

Thank you a lot, I will use that instead


Le 16/02/2018 à 10:21, Laurent Thery a écrit :
>
> On 02/14/2018 02:08 AM, Épiphanie Gédéon wrote:
>> Hello all,
>>
>> I was wondering wether it was possible to coerce strings to a sequence
>> of ascii characters. Right now, I have been able to write this:
>>
>> Definition seq_string := seq ascii.
>>
>> Fixpoint string_to_seq_string (s: string): seq_string := match s with
>> |EmptyString => [::]
>> |String a s => a :: (string_to_seq_string s)
>> end.
>>
>> Coercion string_to_seq_string : string >-> seq_string.
>>
>> However, I am still unable to do this (with test a function over ascii):
>>
>> (map test "Hello")
>>
>> I have to do this:
>>
>> (map test ("Hello": seq_string))
>>
> I am not an expert with coercion but the fact you have introduced an
> intermediate type seq_string may be the problem.
>
> This more direct way of encoding your coercion seems to work:
>
>  From mathcomp Require Import all_ssreflect.
> Require Import Ascii String.
>
> Fixpoint string_to_seq_string (s: string): seq ascii := match s with
> |EmptyString => [::]
> |String a s => a :: (string_to_seq_string s)
> end.
>
> Coercion string_to_seq := string_to_seq_string.
>
> Definition test : ascii -> ascii := id.
>
> Open Scope string_scope.
>
> Check [seq test i | i <- "Hello"].





Archive powered by MHonArc 2.6.18.

Top of Page