<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>【vscode】タグの記事一覧｜Haskell Tech</title>
	<atom:link href="https://haskell-tech.nkhn37.net/tag/vscode/feed/" rel="self" type="application/rss+xml" />
	<link>https://haskell-tech.nkhn37.net</link>
	<description>Haskell学習サイト</description>
	<lastBuildDate>Sun, 07 Jan 2024 05:38:04 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://haskell-tech.nkhn37.net/wp-content/uploads/2023/12/cropped-lion-normal-clear-32x32.png</url>
	<title>【vscode】タグの記事一覧｜Haskell Tech</title>
	<link>https://haskell-tech.nkhn37.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>VSCodeでHaskellの開発環境を構築する方法</title>
		<link>https://haskell-tech.nkhn37.net/vscode-haskell-environment-setting/</link>
					<comments>https://haskell-tech.nkhn37.net/vscode-haskell-environment-setting/#respond</comments>
		
		<dc:creator><![CDATA[naoki-hn]]></dc:creator>
		<pubDate>Sat, 06 Jan 2024 20:00:00 +0000</pubDate>
				<category><![CDATA[開発環境]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[haskell syntax highlighting]]></category>
		<category><![CDATA[vscode]]></category>
		<guid isPermaLink="false">https://haskell-tech.nkhn37.net/?p=105</guid>

					<description><![CDATA[VSCodeを利用してHaskell開発環境を構築する方法について解説します。 VSCodeでHaskell環境準備 VSCode（Visual Studio Code）は様々な言語でソフトウェアを開発するときに使用でき]]></description>
										<content:encoded><![CDATA[
<p>VSCodeを利用して<span class="marker"><strong>Haskell開発環境を構築する方法</strong></span>について解説します。</p>



<h2 class="wp-block-heading">VSCodeでHaskell環境準備</h2>



<p><span class="marker"><strong>VSCode（Visual Studio Code）</strong></span>は様々な言語でソフトウェアを開発するときに使用できるエディターで、マルチプラットフォームにも対応したものです。</p>



<p>VSCodeには、Haskell開発のための<span class="marker"><strong>Haskell拡張機能</strong></span>があり、多くの機能を利用することができます。</p>



<p>本記事では、VSCodeでHaskellプログラミングができる環境を構築する方法を説明します。なお、Haskell自体のインストールは別途必要です。Haskellのインストール方法については「<a href="https://haskell-tech.nkhn37.net/haskell-install-linux/" target="_blank" rel="noreferrer noopener">Haskellのインストール方法 （Linux）</a>」でまとめていますので参考にしてください。</p>



<h3 class="wp-block-heading">VSCodeのインストール</h3>



<p>VSCodeは、<a href="https://code.visualstudio.com/Download" target="_blank" rel="noreferrer noopener">VSCodeダウンロードページ</a>からダウンロードしてインストールを実施してください。各環境ごとに用意されています。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="969" height="576" src="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-15.png" alt="VSCode ダウンロードページ" class="wp-image-107" srcset="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-15.png 969w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-15-300x178.png 300w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-15-768x457.png 768w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-15.png 856w" sizes="(max-width: 969px) 100vw, 969px" /><figcaption class="wp-element-caption"><a href="https://code.visualstudio.com/Download" target="_blank" rel="noreferrer noopener">VSCodeダウンロードページ</a>　※画面構成は変わっている可能性があります。</figcaption></figure>



<h3 class="wp-block-heading">Haskell拡張のインストール</h3>



<p><span class="marker"><strong>Haskell拡張機能</strong></span>をインストールします。VSCodeの画面から以下の手順でHaskell拡張機能をインストールしてください。</p>



<ol class="wp-block-list">
<li>拡張タブを選択する。</li>



<li>検索窓で「haskell」と入力する。</li>



<li>検索された「Haskell」をクリックすると右側にHaskell拡張の説明が表示される。</li>



<li>インストールをクリックしてHaskell拡張をインストールする。</li>
</ol>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="662" src="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16-1024x662.png" alt="VSCode Haskell拡張インストール" class="wp-image-108" srcset="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16-1024x662.png 1024w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16-300x194.png 300w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16-768x496.png 768w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16.png 1200w, https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-16-1024x662.png 856w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>インストールを実行すると「<span class="marker"><strong>Haskell</strong></span>」拡張と共に「<span class="marker"><strong>Haskell Syntax Highlighting</strong></span>」拡張もインストールがされます。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="260" height="172" src="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-17.png" alt="" class="wp-image-109"/></figure>
</div>


<h3 class="wp-block-heading">簡単なプログラムで確認</h3>



<p>VSCodeでの実行を簡単に見てみましょう。VSCodeでtest.hsというファイルを作成し、以下のプログラムを記載します。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: haskell; title: ; notranslate">
-- Test用Haskellプログラム
-- main関数を開始
main = do
    -- テスト出力
    print &quot;Hello World!&quot;
</pre></div>


<p>VSCode上では、以下の画像ようにハイライトされてわかりやすく表示されます。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="414" height="140" src="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-18.png" alt="" class="wp-image-139"/></figure>
</div>


<p>また、上記の「main::IO ()」の部分は、型シグネチャになっていますが、行番号が表示されていません。これは、入力されたプログラムに対して型推論の結果をVSCodeが表示してくれているものです。</p>



<p>Haskellは型推論があるとはいえ、型シグネチャを書くようにするほうがよい考え方です。「main::IO ()」の部分マウスオーバーしてクリックすると以下のようにコードとして反映してくれます。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="414" height="140" src="https://haskell-tech.nkhn37.net/wp-content/uploads/2024/01/image-19.png" alt="" class="wp-image-140"/></figure>
</div>


<p>上記の状態でtest.hsを保存しておきましょう。</p>



<h4 class="wp-block-heading">コンパイルして実行</h4>



<p>VSCodeで[ターミナル]-[新しいターミナル]をクリックして、ターミナルを開きます。test.hsのあるフォルダで以下コマンドを実行してみてください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
ghc test.hs
</pre></div>


<p>すると以下のような形でHaskellプログラムがコンパイルされます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
&#x5B;1 of 2] Compiling Main             ( test.hs, test.o ) &#x5B;Source file changed]
&#x5B;2 of 2] Linking test &#x5B;Objects changed]
</pre></div>


<p>コンパイルされたtest(Windowsの場合は、test.exe)を実行すると以下のように結果が確認できます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
./test
</pre></div>

<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
【実行結果】
&quot;Hello World!&quot;
</pre></div>


<p>このようにすることでVSCode上でHaskellのプログラミングが可能になります。</p>



<h4 class="wp-block-heading">GHCiでロードして実行</h4>



<p>GHCは、インタラクティブな対話シェルが用意されているため、以下のようにターミナル上で以下のように実行することも可能です。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
ghci test.hs
</pre></div>


<p>上記を実行すると以下のように「ghci&gt;」という部分が表示されます。ここで「main」と関数を指定してENTERを押すと結果が出力されます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
GHCi, version 9.4.8: https://www.haskell.org/ghc/  :? for help
&#x5B;1 of 2] Compiling Main             ( test.hs, interpreted )
Ok, one module loaded.
ghci&gt; main
&quot;Hello World!&quot;
</pre></div>


<p>また、以下の例のようにghciを先に起動しておいて、「:l」でファイルをロードしても構いません。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
GHCi, version 9.4.8: https://www.haskell.org/ghc/  :? for help
ghci&gt; :l test.hs
&#x5B;1 of 2] Compiling Main             ( test.hs, interpreted )
Ok, one module loaded.
ghci&gt; main
&quot;Hello World!&quot;
</pre></div>


<p>なお、GHCiから抜ける場合には、「:q」をクリックすることで抜けることができます。</p>



<p>GHCiを使うことでモジュール分割されたファイルの関数を個別に動作確認するといったことも可能となるため非常に便利です。Haskellでは、GHCiで各モジュールの関数を動作確認し、確認が終わったら、GHCでコンパイルするという開発の流れが一般的です。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p>VSCodeを利用して<span class="marker"><strong>Haskell開発環境を構築する方法</strong></span>について解説しました。</p>



<p>VSCodeには、Haskell拡張やHaskell Syntax Highlighting拡張といったものが用意されており、VSCode拡張機能の追加から簡単に追加できます。</p>



<p>VSCodeを使ったHaskell開発環境の構築の参考にしていただければと思います。</p>



<figure class="wp-block-embed is-type-wp-embed is-provider-haskell-tech wp-block-embed-haskell-tech"><div class="wp-block-embed__wrapper">
https://haskell-tech.nkhn37.net/haskell-introduction/
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://haskell-tech.nkhn37.net/vscode-haskell-environment-setting/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Disk: Enhanced  を使用したページ キャッシュ

Served from: haskell-tech.nkhn37.net @ 2026-04-27 00:20:24 by W3 Total Cache
-->