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:
  • Subject: Re: [ssreflect] Coercing strings to seq ascii
  • Date: Fri, 16 Feb 2018 14:16:21 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:HpC6JRFINVc9K2TDloXFv51GYnF86YWxBRYc798ds5kLTJ78oMSwAkXT6L1XgUPTWs2DsrQY07GQ6/iocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmDSwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjDQhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VDK/5KlpVRDokj8KOSMn/mHZisJ+j6xVrxyuqBN934Hab5qYNOZ9c67HYd8WWWRMU8RXWidcAo28dYwPD+8ZMONEt4n9pkMOrRukCgmqBePg1CJDiH7s2qInyeMhFgfG1xEnEt0QqHTUrc31NKcIXuCzzanH0y/Pb/xI1jjg9ofIdRYhrOqDXbJ1a8XRyE0vGxnZgVWXrIzoJjWY3fkOvWiD9+dtV+2ih3Q6pw1vojWj3MQhhpfTio8VxF3I7St0zYQvKdGlSUN2ZcSoHIVNuyyULYd6X8EvTmFutS0n0LMJo4S7czIPyJk/xx7QdfiHc4+Q7xLmTumRIDN4iGtrebK6mxq+6Eagx+3yW8Wu31ZKqS1FktbItn8TzRDc9s+HSv5l8keg3zaAyRzT5/lGLE07j6bXNoAtz74qmpcQr0jPBC/7lUvugK+TbEok++yo6+r9YrXho5+RL5F7ihn/MqQ2msywG+I4MgkQUGSB9uSzyqDs8lP+QLVMlfA2nazZv4rbJcQfvKK2HwhV0oM75xalEzimyMgYnWUALF9dYxKHlJLpNE/AIPD8E/iwn0isnSxwx/HGO73hGo/CImLCkLfnZ7Z96lRTxBA9zdBFtNpoDeQaO+j+VEv8v8DwCwQjdg2y2efuTtR7zIIXH2yVUYGDN6aHEEeJ/uImJeiBLKCUtLf6LbBx6ubvlX8wn14QO6ak0ZYQbli3G/1nJwOSZn+60YRJKnsDogdrFL+is1aFSzMGPy/jDZJ53SkyDcedNamGQ4mshLKb2yLiR89ZY2lHDhaHFnK6LtzYCcdJUzqbJ4paqhJBTaKoEtZz2hSntQu8wL1ifLKNp38o8Kn73d0w3NX90BE/8TsuUpaY2mCJCn5xxiYGGmRw06d4rkhwjFyE1Pogjg==

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