VOOZH about

URL: https://qiita.com/yoshihiro503/items/a6fe93ae0d867129f7b1

⇱ Coqで型クラス #class - Qiita


👁 Image
6

Go to list of users who liked

2

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@yoshihiro503in👁 Image
株式会社proof ninja

Coqで型クラス

6
Last updated at Posted at 2012-12-26
Show.v
RequireImportString.OpenScopestring_scope.(* 型クラスShowの定義 *)ClassShow(A:Set):={show:A->string}.(* フィールドshowの型 *)Check@show.(*
show
 : forall A : Set, Show A -> A -> string
((A:Set)と(s:Show A)の部分は暗黙引数となり、省略可能)
*)(* string型をShowクラスのインスタンスとする *)InstanceShowString:Showstring:={shows:=s}.(* bool型をShowクラスのインスタンスとする *)InstanceShowBool:Showbool:={showb:=matchbwith|true=>"true"|false=>"false"end}.(* 文字列はShowクラスのインスタンス *)Definitionfoo:=show"hello".(* ブール型はShowクラスのインスタンス *)Definitionbar:=showtrue.(* 混ぜても使える *)Definitionhoge:=show"hello"++showfalse.
6

Go to list of users who liked

2
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6

Go to list of users who liked

2