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: Jason Gross <>
  • To: Épiphanie Gédéon <>
  • Cc:
  • Subject: Re: [ssreflect] Coercing strings to seq ascii
  • Date: Fri, 16 Feb 2018 15:50:53 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:6O4TfB0M82+a/fDdsmDT+DRfVm0co7zxezQtwd8Zse0RKPad9pjvdHbS+e9qxAeQG9mDsLQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPbQhEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7Vq4/Vyi84Kh3SR/okCYHOCA/8GHLkcx7kaZXrAu8qxBj34LYZYeYP+d8cKzAZ9MXXWVOXshTWCJBDI2ybJYBAfQdMutDtYbxu0EDoAGiCQWwBu7izCJDiH/s3a091uQsCQXI0xY7H9IJtnTfsdT7NL0VUeCu16nD0DLOb/FM1jfm74jIdB8hoeuLXbJrasrczVIiFwzAjlqKqIzlOymZ2fgKs2ie9udtU/+khW0/qwxpvDSj2sMhhpPKi48V0FzI6zt1zJovKdGlSkN2YNipG4ZKuS6ALYt5WMYiTnlouCkkzr0Gvoa2fC0Qx5Qmwx7TcuWHc4uU7h76WuadPDV1iXN/dLKwgBay9kegyuniWcWuzFlKqS9FnsHNtnALyRPT9tCKRuVh8kqlwzqC1ADe5vtaLUwqiabXMYMtz7wxm5YLtETMBC72mEH4jK+McUUk//Cl6+b9bbX9oZ+cMYB0ihv5MqQ1gcyyBf81MgcLX2eB+OS80Kfv8lH+QLVPlvE2iLXWsIjGJcQHoa60GxRV0p056xmhATem1MoXkmUbLF9eYxKGj43pO0nUL/ziDPe/hU6skDZxyPzcML3hGMaFEn+WMa/gZbZ07U9RgCWywVFY4doAB6kAOPL6XE788tPVAhI+NSS7xu/mDJN20YZICkyVBarMEqrJtlnAyfgoOPLEMI0cozH7JOIi/OW/pXA8kF4ZO6Ku2M1EOziDAv16LhDBMjLXidAbHDJP51JmFb24uBi5STdWIk2Kcec57zA/BpihCN6aFI+oib2Fmiy8G88PPzwUOhW3CX7tMr68dbIUcivLe51ulzUFUf6qTIpzjUjz5j+/8KJuK6/vwgNdtZ/n04IrtejalBV37D8sSsrEjD/LQGZzkWcFATQx2fInrA==

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