## `msgid`s in this file come from POT (.pot) files.
##
## Do not add, change, or remove `msgid`s manually here as
## they're tied to the ones in the corresponding POT file
## (with the same domain).
##
## Use `mix gettext.extract --merge` or `mix gettext.merge`
## to merge POT files into PO files.
msgid ""
msgstr ""
"Language: en\n"

#: web/templates/layout/app.html.eex
msgid "Default Title"
msgstr "POST Bot for Slack"

msgid "Default Description"
msgstr "A Slack bot to get valuable feedback on your articles."

#: web/templates/page/index.html.eex:2
msgid "Welcome to %{name}"
msgstr ""

msgid "Initial Greeting"
msgstr "Hi! I'm POST. I help journalists by suggesting the right action at the right moment.\n\n"
  "Use the `/add` command to add a new article url."

msgid "Message Spike"
msgstr "Your article `%{article_url}` is very popular at the moment, the pageviews increased by %{count} in the last half an hour."

msgid "Article Confirm Prompt"
msgstr "Okay, you'd like to register the article at %{url}"

msgid "Article Confirm"
msgstr "Yes, that's it."

msgid "Article Refute"
msgstr "Nope"

msgid "Article Registered"
msgstr "Okay, great, I've registered %{url}"

msgid "Article Retry"
msgstr "ok, can you try adding it with `/add` again please?"

Change copy for initial greeting message

## `msgid`s in this file come from POT (.pot) files.
##
## Do not add, change, or remove `msgid`s manually here as
## they're tied to the ones in the corresponding POT file
## (with the same domain).
##
## Use `mix gettext.extract --merge` or `mix gettext.merge`
## to merge POT files into PO files.
msgid ""
msgstr ""
"Language: en\n"

#: web/templates/layout/app.html.eex
msgid "Default Title"
msgstr "POST Bot for Slack"

msgid "Default Description"
msgstr "A Slack bot to get valuable feedback on your articles."

#: web/templates/page/index.html.eex:2
msgid "Welcome to %{name}"
msgstr ""

msgid "Initial Greeting"
msgstr "Hi! I'm POST. I help journalists by suggesting the right action at the right moment.\n\n"
  "We're almost ready to go, please complete the setup here: https://espi-dni.herokuapp.com/setup."

msgid "Message Spike"
msgstr "Your article `%{article_url}` is very popular at the moment, the pageviews increased by %{count} in the last half an hour."

msgid "Article Confirm Prompt"
msgstr "Okay, you'd like to register the article at %{url}"

msgid "Article Confirm"
msgstr "Yes, that's it."

msgid "Article Refute"
msgstr "Nope"

msgid "Article Registered"
msgstr "Okay, great, I've registered %{url}"

msgid "Article Retry"
msgstr "ok, can you try adding it with `/add` again please?"


## `msgid`s in this file come from POT (.pot) files.
##
## Do not add, change, or remove `msgid`s manually here as
## they're tied to the ones in the corresponding POT file
## (with the same domain).
##
## Use `mix gettext.extract --merge` or `mix gettext.merge`
## to merge POT files into PO files.
msgid ""
msgstr ""
"Language: en\n"
"Plural-Forms: nplurals=2\n"

#, elixir-format
#: lib/atom_tweaks_web/templates/page/about.html.slime:1
msgid "about_atom_tweaks"
msgstr "# About Atom Tweaks\n"
"\n"
"Atom Tweaks is a database of simple tweaks for the [Atom text editor](https://atom.io). These\n"
"are simple changes to one's environment that don't merit a full\n"
"[Atom package](https://atom.io/packages). Atom is very customizable because you can add these\n"
"small snippets that can radically change your editing environment. In the past, finding and\n"
"integrating these little chunks of code was a time-consuming and error-prone process. Atom\n"
"Tweaks seeks to solve all of that!\n"
"\n"
"-----\n"
"\n"
"_Atom and the Atom logo are registered trademarks of GitHub, Inc._\n"

Add some more explanation text to the about page

## `msgid`s in this file come from POT (.pot) files.
##
## Do not add, change, or remove `msgid`s manually here as
## they're tied to the ones in the corresponding POT file
## (with the same domain).
##
## Use `mix gettext.extract --merge` or `mix gettext.merge`
## to merge POT files into PO files.
msgid ""
msgstr ""
"Language: en\n"
"Plural-Forms: nplurals=2\n"

#, elixir-format
#: lib/atom_tweaks_web/templates/page/about.html.slime:1
msgid "about_atom_tweaks"
msgstr "# About Atom Tweaks\n"
"\n"
"Atom Tweaks is a database of simple tweaks for the [Atom text editor](https://atom.io). These\n"
"are simple changes to one's environment that don't merit a full\n"
"[Atom package](https://atom.io/packages). Atom is very customizable because you can add these\n"
"small snippets that can radically change your editing environment. In the past, finding and\n"
"integrating these little chunks of code was a time-consuming and error-prone process. Atom\n"
"Tweaks seeks to solve this problem by providing a place where everyone can share their tips\n"
"and tricks with each other.\n"
"\n"
"Take a look at the tweaks that others have shared, then give it a try and share your own!\n"
"\n"
"-----\n"
"\n"
"_Atom and the Atom logo are registered trademarks of GitHub, Inc._\n"


#: source.py:1 source.py:2
msgid "translatable_string_id_%s"
msgstr "Плохая, негодная %(строка)s!"

#: source.py:3
msgid "fuzzy_string"
msgstr "Строка как строка"


Add uk translation difference of Pipeline Schedules

# Андрей Витюк <andruwa13@gmail.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 21:59-0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-07-12 07:29-0400\n"
"Last-Translator: Андрей Витюк <andruwa13@gmail.com>\n"
"Language-Team: Ukrainian\n"
"Language: uk\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"

msgid "PipelineSchedules|Input variable key"
msgstr "Введіть ім'я змінної"

msgid "PipelineSchedules|Input variable value"
msgstr "Вхідні значення змінних"

msgid "PipelineSchedules|Remove variable row"
msgstr "Видалити змінні"

msgid "PipelineSchedules|Variables"
msgstr "Змінні"

msgid ""
"You are going to remove %{group_name}.\n"
"Removed groups CANNOT be restored!\n"
"Are you ABSOLUTELY sure?"
msgstr ""
"Ви хочете видалити %{group_name}.\n"
"Видалені групи НЕ МОЖНА буду відновити!\n"
"Ви АБСОЛЮТНО впевнені?"


Add Japanese translation. Thanks Jonas Obrist.

msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/aaugustin/django-sequences/issues\n"
"POT-Creation-Date: 2016-01-06 06:34-0600\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"

msgid "Sequences"
msgstr "シーケンス"

msgid "name"
msgstr "名前"

msgid "last value"
msgstr "最大数字"

msgid "sequence"
msgstr "シーケンス"

msgid "sequences"
msgstr "シーケンス"


# Italian translation of libwnck.
# Copyright (C) 2002 Free Software Foundation, Inc.
# Pier Luigi Fiorini <plfiorini@libero.it>, 2002.
#
msgid ""
msgstr ""
"Project-Id-Version: libwnck 0.7\n"
"POT-Creation-Date: 2002-04-06 06:55+0200\n"
"PO-Revision-Date: 2002-04-10 18:38+0200\n"
"Last-Translator: Pier Luigi Fiorini <plfiorini@libero.it>\n"
"Language-Team: Italiano <tp@lists.linux.it>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 0.9.6\n"

#: libwnck/application.c:25
msgid "untitled application"
msgstr "applicazione senza nome"

#: libwnck/window-action-menu.c:154
msgid "Un_minimize"
msgstr "De_minimizza"

#: libwnck/window-action-menu.c:160
msgid "_Minimize"
msgstr "_Minimizza"

#: libwnck/window-action-menu.c:167
msgid "_Unmaximize"
msgstr "Dema_ssimizza"

#: libwnck/window-action-menu.c:173
msgid "Ma_ximize"
msgstr "Ma_ssimizza"

#: libwnck/window-action-menu.c:180
msgid "U_nshade"
msgstr "Sr_otola"

#: libwnck/window-action-menu.c:186
msgid "_Shade"
msgstr "_Arrotola"

#: libwnck/window-action-menu.c:297
msgid "Close"
msgstr "Chiudi"

#: libwnck/window-action-menu.c:318
msgid "Mo_ve"
msgstr "S_posta"

#: libwnck/window-action-menu.c:324
msgid "_Resize"
msgstr "R_idimensiona"

#: libwnck/window.c:29
msgid "untitled window"
msgstr "finestra senza titolo"

#: libwnck/workspace.c:248
#, c-format
msgid "Workspace %d"
msgstr "Area di lavoro %d"


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-07-13 08:16+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2)\n"

#: admin.py:76
msgid "Move"
msgstr "Déplacer"

#: models.py:67
msgid ""
"The method move() is deprecated and will be removed in the next release."
msgstr ""
"La méthode move() est dépréciée et sera supprimée dans la prochaine version."

#: models.py:80
msgid ""
"The method move_down() is deprecated and will be removed in the next "
"release. Please use down() instead!"
msgstr ""
"La méthode move_down() est dépréciée et sera supprimée dans la prochaine "
"version. Merci d'utiliser down() à la place !"

#: models.py:90
msgid ""
"The method move_up() is deprecated and will be removed in the next release. "
"Please use up() instead!"
msgstr ""
"La méthode move_up() est dépréciée et sera supprimée dans la prochaine "
"version. Merci d'utiliser up() à la place !"


Add Traditional Chinese in HongKong translations of Commits Page

# Huang Tao <htve@outlook.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 21:59-0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-06-23 01:23-0400\n"
"Last-Translator: Huang Tao <htve@outlook.com>\n"
"Language-Team: Chinese (Hong Kong SAR China)\n"
"Language: zh-HK\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=1; plural=0\n"

msgid "%d additional commit have been omitted to prevent performance issues."
msgid_plural ""
"%d additional commits have been omitted to prevent performance issues."
msgstr[0] "為提高頁面加載速度及性能，已省略了 %d 次提交。"

msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] " %d 次提交"

msgid "BranchSwitcherPlaceholder|Search branches"
msgstr "搜索分支"

msgid "BranchSwitcherTitle|Switch branch"
msgstr "切換分支"

msgid "Browse Directory"
msgstr "瀏覽目錄"

msgid "Browse File"
msgstr "瀏覽文件"

msgid "Browse Files"
msgstr "瀏覽文件"

msgid "Commits feed"
msgstr "提交動態"

msgid "Filter by commit message"
msgstr "按提交消息過濾"

msgid "UploadLink|click to upload"
msgstr "點擊上傳"

msgid "View open merge request"
msgstr "查看開啟的合並請求"


Add Swedish translation. Thanks Andreas Pelme.

msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/aaugustin/django-sequences/issues\n"
"POT-Creation-Date: 2016-01-06 06:24-0600\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "Sequences"
msgstr "Sekvenser"

msgid "name"
msgstr "namn"

msgid "last value"
msgstr "senast värde"

msgid "sequence"
msgstr "sekvens"

msgid "sequences"
msgstr "sekvenser"


Add Traditional Chinese in Taiwan translations of Commits Page

# Huang Tao <htve@outlook.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 21:59-0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-06-23 01:23-0400\n"
"Last-Translator: Huang Tao <htve@outlook.com>\n"
"Language-Team: Chinese (Taiwan)\n"
"Language: zh-TW\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=1; plural=0\n"

msgid "%d additional commit have been omitted to prevent performance issues."
msgid_plural ""
"%d additional commits have been omitted to prevent performance issues."
msgstr[0] "為提高頁面加載速度及性能，已省略了 %d 次送交 (commit)。"

msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] "%d 次送交 (commit)"

msgid "BranchSwitcherPlaceholder|Search branches"
msgstr "搜索分支 (branches)"

msgid "BranchSwitcherTitle|Switch branch"
msgstr "切換分支 (branch)"

msgid "Browse Directory"
msgstr "瀏覽目錄"

msgid "Browse File"
msgstr "瀏覽檔案"

msgid "Browse Files"
msgstr "瀏覽檔案"

msgid "Commits feed"
msgstr "送交動態"

msgid "Filter by commit message"
msgstr "按送交消息過濾"

msgid "UploadLink|click to upload"
msgstr "點擊上傳"

msgid "View open merge request"
msgstr "查看開啟的合並請求  (merge request)"


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-04 10:48+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

msgid "Location"
msgstr "Emplacement"

msgid "Name"
msgstr "Nom"

msgid "Description"
msgstr "Description"

msgid "External id"
msgstr "ID externe"

msgid "Site"
msgstr "Site"

msgid "Sites"
msgstr "Sites"

msgid "Treks"
msgstr "Itinéraires"

msgid "POIs"
msgstr "POI"

msgid "Trails"
msgstr "Sentiers"

msgid "Infrastructures"
msgstr "Aménagements"

msgid "Signages"
msgstr "Signalétiques"

msgid "Touristic contents"
msgstr "Contenus touristiques"

msgid "Touristic events"
msgstr "Événements touristiques"

msgid "Cities"
msgstr "Communes"

msgid "Districts"
msgstr "Secteurs"

msgid "Restricted areas"
msgstr "Zonages réglementaires"

msgid "Outdoor"
msgstr "Outdoor"

msgid "Add a new site"
msgstr "Ajouter un nouveau site"

msgid "Invalid geometry value."
msgstr "Valeur de géométrie invalide"


# Russian (Russia) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: 2007-07-30 22:18+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: ru_RU <LL@li.org>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9dev-r363\n"

#. This will be a translator coment,
#. that will include several lines
#: project/file1.py:8
msgid "bar"
msgstr ""

#: project/file2.py:9
msgid "foobar"
msgid_plural "foobars"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""


Add Esperanto translations of Commits Page

#
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 21:59-0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: Esperanto\n"
"Language: eo\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"

msgid "%d additional commit have been omitted to prevent performance issues."
msgid_plural ""
"%d additional commits have been omitted to prevent performance issues."
msgstr[0] ""
msgstr[1] ""

msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] ""
msgstr[1] ""

msgid "BranchSwitcherPlaceholder|Search branches"
msgstr ""

msgid "BranchSwitcherTitle|Switch branch"
msgstr ""

msgid "Browse Directory"
msgstr ""

msgid "Browse File"
msgstr ""

msgid "Browse Files"
msgstr ""

msgid "Commits feed"
msgstr ""

msgid "Filter by commit message"
msgstr ""

msgid "UploadLink|click to upload"
msgstr ""

msgid "View open merge request"
msgstr ""


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-08-08 22:36-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: models.py:11
msgid "Profile Name"
msgstr ""

#: models.py:13
msgid "Comment"
msgstr ""

#: models.py:14
msgid "Comment count"
msgstr ""

#: models.py:15
msgid "Date added"
msgstr ""

#: models.py:21
msgid "Top Comment"
msgstr ""

#: models.py:22
msgid "Top Comments"
msgstr ""


Add Slovak translation. Thanks Michal Petrucha.

msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/aaugustin/django-sequences/issues\n"
"POT-Creation-Date: 2016-01-06 06:36-0600\n"
"Language: sk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

msgid "Sequences"
msgstr "Postupnosti"

msgid "name"
msgstr "meno"

msgid "last value"
msgstr "posledná hodnota"

msgid "sequence"
msgstr "postupnosť"

msgid "sequences"
msgstr "postupnosti"


Add Simplified Chinese translations of Commits Page

# Huang Tao <htve@outlook.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-15 21:59-0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-06-23 01:04-0400\n"
"Last-Translator: Huang Tao <htve@outlook.com>\n"
"Language-Team: Chinese (China)\n"
"Language: zh-CN\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=1; plural=0\n"

msgid "%d additional commit have been omitted to prevent performance issues."
msgid_plural ""
"%d additional commits have been omitted to prevent performance issues."
msgstr[0] "为提高页面加载速度及性能，已省略了 %d 次提交。"

msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] "%d 次提交"

msgid "BranchSwitcherPlaceholder|Search branches"
msgstr "搜索分支"

msgid "BranchSwitcherTitle|Switch branch"
msgstr "切换分支"

msgid "Browse Directory"
msgstr "浏览目录"

msgid "Browse File"
msgstr "浏览文件"

msgid "Browse Files"
msgstr "浏览文件"

msgid "Commits feed"
msgstr "提交动态"

msgid "Filter by commit message"
msgstr "按提交消息过滤"

msgid "UploadLink|click to upload"
msgstr "点击上传"

msgid "View open merge request"
msgstr "查看开启的合并请求"


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-25 16:40+0200\n"
"PO-Revision-Date: 2015-10-21 11:16+0200\n"
"Last-Translator: jean-etienne.castagnede@makina-corpus.com\n"
"Language-Team: \n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.8.4\n"

#, python-format
msgid "%s days"
msgstr "%s tage"


Add translated strings for the website app

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-02-02 12:08+0100\n"
"PO-Revision-Date: 2017-02-02 12:20+0100\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: Jip J. Dekker <jip@dekker.li>\n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.11\n"

#: settings/base.py:114
msgid "English"
msgstr "Engelska"

#: settings/base.py:115
msgid "Swedish"
msgstr "Svenska"


Add Brazilian Portuguese Translation (pt_BR)

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-19 17:52+0300\n"
"PO-Revision-Date: 2017-10-02 14:15-0300\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
"%100>=11 && n%100<=14)? 2 : 3);\n"
"Last-Translator: Diego Rabatone Oliveira <diraol@diraol.eng.br>\n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.11\n"

#: admin.py:14
msgid "Addition"
msgstr "Adiçao"

#: admin.py:15
msgid "Deletion"
msgstr "Remoção"

#: admin.py:16
msgid "Change"
msgstr "Alteração"

#: admin.py:21 admin.py:162
msgid "Action"
msgstr "Ação"

#: admin.py:34
msgid "staff user"
msgstr "usuário administrativo"

#: admin.py:58
msgid "Metadata"
msgstr "Metadados"

#: admin.py:66
msgid "Detail"
msgstr "Detalhes"

#: admin.py:130
msgid "object"
msgstr "item"

#: admin.py:148
msgid "user"
msgstr "usuário"

#: admin.py:166
msgid "change message"
msgstr "alteração"


Add Romansh translation. Thanks Benjamin Wohlwend.

msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/aaugustin/django-sequences/issues\n"
"POT-Creation-Date: 2016-01-06 06:14-0600\n"
"Language: rm\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "Sequences"
msgstr "Sequenza"

msgid "name"
msgstr "nom"

msgid "last value"
msgstr "ultim valur"

msgid "sequence"
msgstr "sequenza"

msgid "sequences"
msgstr "sequenzas"


# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-23 12:53+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

Update translation terms from Transifex adhoc-odoo-15-0

# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-24 13:03+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-05-26 14:35-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"

#: popthelp.c:23
msgid "Show this help message"
msgstr ""

#: popthelp.c:24
msgid "Display brief usage message"
msgstr ""

Duplicate query aliases onto rpmq.

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-05-31 13:35-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"

#: popthelp.c:23
msgid "Show this help message"
msgstr ""

#: popthelp.c:24
msgid "Display brief usage message"
msgstr ""


# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-20 12:22+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

Update translation terms from Transifex adhoc-odoo-15-0

# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-21 12:32+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"


# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-22 12:42+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

Update translation terms from Transifex adhoc-odoo-15-0

# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-23 12:53+0000\n"
"PO-Revision-Date: 2022-04-19 15:18+0000\n"
"Language-Team: Spanish (https://www.transifex.com/adhoc/teams/133229/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"


msgid ""
"First, type in the name of the UK public authority you'd \n"
"
like information from. By law, they have to respond\n"
"           (why?)."
msgstr "bah"
"First, type in the name of the public authority you'd \n"
"
like information from. By law, they have to respond\n"
"           (why?)."

msgid "Summary:"
msgstr "Subject:"

Remove test string from locale file

msgid ""
"First, type in the name of the UK public authority you'd \n"
"
like information from. By law, they have to respond\n"
"           (why?)."
msgstr ""
"First, type in the name of the public authority you'd \n"
"
like information from. By law, they have to respond\n"
"           (why?)."

msgid "Summary:"
msgstr "Subject:"


# Copyright (C) 2017
# This file is distributed under the same license as the Example Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Example Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/plugin-with-pot\n"
"POT-Creation-Date: 2016-09-14 23:53:41+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

#. Plugin Name of the plugin/theme
msgid "Example Plugin"
msgstr ""

Update dates in fixture to prevent failed tests.

# Copyright (C) 2018
# This file is distributed under the same license as the Example Plugin package.
msgid ""
msgstr ""
"Project-Id-Version: Example Plugin\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/plugin-with-pot\n"
"POT-Creation-Date: 2016-09-14 23:53:41+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

#. Plugin Name of the plugin/theme
msgid "Example Plugin"
msgstr ""


# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# 	* metro_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0-20130413-232416\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-21 00:23+0000\n"
"PO-Revision-Date: 2013-12-21 08:25+0800\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.7\n"

#. module: metro_accounts
#: field:account.voucher,supplier_receipt_number:0
msgid "Supplier Receipt Number"
msgstr "税"

Change the supplier receipt i18n

# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# 	* metro_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0-20130413-232416\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-12-21 00:23+0000\n"
"PO-Revision-Date: 2013-12-21 08:25+0800\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.7\n"

#. module: metro_accounts
#: field:account.voucher,supplier_receipt_number:0
msgid "Supplier Receipt Number"
msgstr "供应商发票号"


# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-12-21 15:28+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: staff/admin.py:33
msgid "employee"
msgstr "employé"

Refresh fr locale for staff module.

# Locale strings for staff module.
# Copyright (c) 2016 nVentiveUX
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#, fuzzy
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-08 18:31+0100\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: staff/admin.py:33
msgid "employee"
msgstr "employé"


module Main

import Data.String.Parser
import Control.Monad.Identity
import Control.Monad.Trans

%default partial
-- Buld this program with '-p contrib'

parseStuff : ParseT IO ()
parseStuff = do a <- string "abc"
                lift $ putStrLn "hiya"
                b <- string "def"
                pure ()

main : IO ()
main = do
    res <- parseT parseStuff "abcdef"
    res <- parseT (string "hi") "hideous"
    case res of
        Left err => putStrLn "NOOOOOOO!"
        Right () => putStrLn "YEEEES!"
    digs <- parseT (satisfy isDigit) "8878993"
    case digs of
        Left err => putStrLn "NOOOOOOO!"
        Right ds => printLn ds
    migs <- parseT (many (satisfy isDigit)) "766775"
    case migs of
        Left err => putStrLn "NOOOOOOO!"
        Right ds => printLn ds
    pure ()

Expand test code a bit with pure parsing

module Main

import Data.String.Parser
import Control.Monad.Identity
import Control.Monad.Trans

%default partial
-- Buld this program with '-p contrib'

parseStuff : ParseT IO ()
parseStuff = do a <- string "abc"
                lift $ putStrLn "hiya"
                b <- string "def"
                pure ()

pureParsing : String -> Either String (List Char)
pureParsing str = parse (many (satisfy isDigit)) str

main : IO ()
main = do
    res <- parseT parseStuff "abcdef"
    res <- parseT (string "hi") "hideous"
    case res of
        Left err => putStrLn "NOOOOOOO!"
        Right () => putStrLn "YEEEES!"
    digs <- parseT (satisfy isDigit) "8878993"
    case digs of
        Left err => putStrLn "NOOOOOOO!"
        Right ds => printLn ds
    migs <- parseT (many (satisfy isDigit)) "766775"
    case migs of
        Left err => putStrLn "NOOOOOOO!"
        Right ds => printLn ds
    let pp = pureParsing "63553"
    case pp of
        Left err => putStrLn err
        Right xs => printLn xs
    pure ()


module Prelude.Pairs

import Builtins

%access public
%default total

using (a : Type, P : a -> Type)

    ||| Dependent pair where the first field is erased.
    data Exists : (P : a -> Type) -> Type where
        evidence : .(x : a) -> (pf : P x) -> Exists P

    ||| Dependent pair where the second field is erased.
    data Subset : (a : Type) -> (P : a -> Type) -> Type where
        element : (x : a) -> .(pf : P x) -> Subset a P

    ||| The type class of dependent pairs.
    class DepPair (a : Type) (P : a -> Type) (T : Type) where

        ||| The first projection from a dependent pair.
        getWitness : (x : T) -> a

        ||| The second projection from a dependent pair.
        getProof : (x : T) -> P (getWitness x)

    instance DepPair a P (Exists {a} P) where
        getWitness (evidence x pf) = x
        getProof   (evidence x pf) = pf

    instance DepPair a P (Subset a P) where
        getWitness (element x pf) = x
        getProof   (element x pf) = pf

    instance DepPair a P (Pair a P) where
        getWitness (pair x pf) = x
        getProof   (pair x pf) = pf

Fix indentation, use monomorphic projections for pairs.

module Prelude.Pairs

import Builtins

%access public
%default total

using (a : Type, P : a -> Type)

  ||| Dependent pair where the first field is erased.
  data Exists : (P : a -> Type) -> Type where
    evidence : .(x : a) -> (pf : P x) -> Exists P

  ||| Dependent pair where the second field is erased.
  data Subset : (a : Type) -> (P : a -> Type) -> Type where
    element : (x : a) -> .(pf : P x) -> Subset a P

  -- Monomorphic projections

  namespace Exists
    getWitness : Exists {a} P -> a
    getWitness (evidence x pf) = x

    getProof : (x : Exists {a} P) -> P (getWitness x)
    getProof (evidence x pf) = pf

  namespace Subset
    getWitness : Subset a P -> a
    getWitness (element x pf) = x

    getProof : (x : Subset a P) -> P (getWitness x)
    getProof (element x pf) = pf

  namespace Pair
    getWitness : Pair a P -> a
    getWitness (pair x pf) = x

    getProof : (x : Pair a P) -> P (getWitness x)
    getProof (pair x pf) = pf

  -- Polymorphic (class-based) projections have been removed
  -- because type-directed name disambiguation works better.


module Main

import Core.Context
import Compiler.Common
import Idris.Driver

compile : Ref Ctxt Defs -> (tmpDir : String) -> (execDir : String) ->
          ClosedTerm -> (outfile : String) -> Core (Maybe String)
compile defs tmp dir term file = do coreLift $ putStrLn "I'd rather not."
                                    pure $ Nothing

execute : Ref Ctxt Defs -> (execDir : String) -> ClosedTerm -> Core ()
execute defs dir term = do coreLift $ putStrLn "Maybe in an hour."

lazyCodegen : Codegen
lazyCodegen = MkCG compile execute

main : IO ()
main = mainWithCodegens [("lazy", lazyCodegen)]

Update API test for new Codegen fields

module Main

import Core.Context
import Compiler.Common
import Idris.Driver

compile : Ref Ctxt Defs -> (tmpDir : String) -> (execDir : String) ->
          ClosedTerm -> (outfile : String) -> Core (Maybe String)
compile defs tmp dir term file = do coreLift $ putStrLn "I'd rather not."
                                    pure $ Nothing

execute : Ref Ctxt Defs -> (execDir : String) -> ClosedTerm -> Core ()
execute defs dir term = do coreLift $ putStrLn "Maybe in an hour."

lazyCodegen : Codegen
lazyCodegen = MkCG compile execute Nothing Nothing

main : IO ()
main = mainWithCodegens [("lazy", lazyCodegen)]


import Network.Socket
import Http
import Http.Uri
import Http.RawResponse
import Http.Request
import Http.Response

main : IO ()
main = do
  let a = MkURIAuth Nothing Nothing "4.da.gd" 80
  let b = MkURI "http" a "/ip" "" ""
  let c = MkRequest HEAD b [] [("Host", "4.da.gd")]
  res <- sendRequest c
  case res of
    Left err => print "error"
    Right s => print (responseStatus s)

Make "simple" a bit more flexible

import Http
import Http.Uri
import Http.RawResponse
import Http.Request
import Http.Response
import Network.Socket
import System

uri : String -> Int -> String -> URI
uri host port path = MkURI "http" (MkURIAuth Nothing Nothing host port) path "" ""

toRequest : Method -> String -> Int -> String -> Request
toRequest method host port path = MkRequest method (uri host port path) [] [("Host", host)]

processArgs : List String -> Maybe Request
processArgs (_::method::host::path::_) = Just (toRequest (cast method) host 80 path)
processArgs (_::method::host::port::path::_) =
  Just (toRequest (cast method) host (cast port) path)
processArgs _ = Nothing

partial
main : IO ()
main = do
  args <- getArgs
  case processArgs args of
    Just req => do
      res <- sendRequest req
      case res of
        Left err => print err >>= \_ => putStr "\n"
        Right s => print (responseStatus s) >>= \_ => putStr "\n"
    Nothing => putStrLn "Usage: ./simple method host [port] path"


module Data.String.Iterator

export
record StringIterator where
  constructor MkSI
  string : String

  -- backend-dependent offset into the string
  -- see prim__readChar below
  offset : Int

export
fromString : String -> StringIterator
fromString s = MkSI s 0

private
data ReadResult
  = EOF
  | Character Char Int  -- character, width

-- takes a backend-dependent offset into the string
-- on ML-based backends, this is in bytes
-- in Scheme, this is in codepoints
private
%foreign "scheme:read-string-char"
prim__readChar : Int -> String -> ReadResult

export
uncons : StringIterator -> Maybe (Char, StringIterator)
uncons (MkSI s ofs) =
  case prim__readChar ofs s of
    EOF => Nothing
    Character ch width => Just (ch, MkSI s (ofs + width))

export
foldl : (a -> Char -> a) -> a -> String -> a
foldl f acc s = loop 0 acc
  where
    loop : Int -> a -> a
    loop ofs acc =
      case prim__readChar ofs s of
        EOF => acc
        Character ch width => loop (ofs + width) (f acc ch)

Make the comments more explicit.

module Data.String.Iterator

export
record StringIterator where
  constructor MkSI
  string : String

  -- backend-dependent offset into the string
  -- see prim__readChar below
  offset : Int

export
fromString : String -> StringIterator
fromString s = MkSI s 0

private
data ReadResult
  = EOF
  | Character Char Int  -- character + width in backend-dependent units

-- Runs in O(1) time.
-- Takes a backend-dependent offset into the string.
-- On ML-based backends, this is in bytes;
-- in Scheme, this is in codepoints.
private
%foreign "scheme:read-string-char"
prim__readChar : Int -> String -> ReadResult

export
uncons : StringIterator -> Maybe (Char, StringIterator)
uncons (MkSI s ofs) =
  case prim__readChar ofs s of
    EOF => Nothing
    Character ch width => Just (ch, MkSI s (ofs + width))

export
foldl : (a -> Char -> a) -> a -> String -> a
foldl f acc s = loop 0 acc
  where
    loop : Int -> a -> a
    loop ofs acc =
      case prim__readChar ofs s of
        EOF => acc
        Character ch width => loop (ofs + width) (f acc ch)


module Http

import Http.Uri
import Http.Request
import Network.Socket

%access public

data RawResponse = MkRawResponse String

sendRequest : Request -> IO (Either SocketError RawResponse)
sendRequest req = do
  print (resolveRequest req)
  case !(socket AF_INET Stream 0) of
    Left err   => return (Left err)
    Right sock =>
      case !(connect sock (Hostname (uriHost . uriAuthority . uri $ req)) (uriPort . uriAuthority . uri $ req)) of
        0 =>
          case !(send sock (resolveRequest req)) of
            Left err => return (Left err)
            Right _  =>
              case !(recv sock 65536) of
                Left err       => return (Left err)
                Right (str, _) => return (Right (MkRawResponse str))
        err => return (Left err)

Fix way long line

module Http

import Http.Uri
import Http.Request
import Network.Socket

%access public

data RawResponse = MkRawResponse String

sendRequest : Request -> IO (Either SocketError RawResponse)
sendRequest req = do
    print (resolveRequest req)
    case !(socket AF_INET Stream 0) of
      Left err   => return (Left err)
      Right sock =>
        case !(connect sock (Hostname host) port) of
          0 =>
            case !(send sock (resolveRequest req)) of
              Left err => return (Left err)
              Right _  =>
                case !(recv sock 65536) of
                  Left err       => return (Left err)
                  Right (str, _) => return (Right (MkRawResponse str))
          err => return (Left err)
  where
    host : String
    host = uriHost . uriAuthority . uri $ req

    port : Int
    port = uriPort . uriAuthority . uri $ req


-- Copyright (c) 2013 Radek Micek

module Common

infixr 1 ??, >=>

(??) : a -> (a -> b) -> b
a ?? f = f a

(>=>) : Monad m => (a -> m b) -> (b -> m c) -> a -> m c
f >=> g = \a => f a >>= g

mapM_ : Monad m => (a -> m b) -> List a -> m ()
mapM_ f = sequence_ . map f

boolToInt : Bool -> Int
boolToInt b = b ? 1 : 0

Add monadic functions filterM and mapTupleM

-- Copyright (c) 2013 Radek Micek

module Common

infixr 1 ??, >=>

(??) : a -> (a -> b) -> b
a ?? f = f a

(>=>) : Monad m => (a -> m b) -> (b -> m c) -> a -> m c
f >=> g = \a => f a >>= g

filterM : Monad m => (a -> m Bool) -> List a -> m (List a)
filterM _ [] = return List.Nil
filterM p (x :: xs) = do
  b <- p x
  ys <- filterM p xs
  return (b ? List.(::) x ys : ys)

mapTupleM : Monad m => (a -> m b) -> (a, a) -> m (b, b)
mapTupleM f (x, y) = do
  x' <- f x
  y' <- f y
  return (x', y')

mapM_ : Monad m => (a -> m b) -> List a -> m ()
mapM_ f = sequence_ . map f

boolToInt : Bool -> Int
boolToInt b = b ? 1 : 0


module Data.Nat

%default total

diff : Nat -> Nat -> Nat
diff k Z = k
diff Z j = j
diff (S k) (S j) = diff k j

Add `ltePlus` and `lteMult` to contrib.

module Data.Nat

%default total
%access public export

diff : Nat -> Nat -> Nat
diff k Z = k
diff Z j = j
diff (S k) (S j) = diff k j

ltePlus : LTE m1 n1 -> LTE m2 n2 -> LTE (m1 + m2) (n1 + n2)
ltePlus {n1=Z} LTEZero lte = lte
ltePlus {n1=S k} LTEZero lte = lteSuccRight $ ltePlus {n1=k} LTEZero lte
ltePlus (LTESucc lte1) lte2 = LTESucc $ ltePlus lte1 lte2

lteCongPlus : (k : Nat) -> LTE m n -> LTE (m + k) (n + k)
lteCongPlus k lte = ltePlus lte lteRefl

lteMult : LTE m1 n1 -> LTE m2 n2 -> LTE (m1 * m2) (n1 * n2)
lteMult LTEZero _ = LTEZero
lteMult {m1=S k} (LTESucc _) LTEZero = rewrite multZeroRightZero k in LTEZero
lteMult (LTESucc lte1) (LTESucc lte2) = LTESucc $ ltePlus lte2 $ lteMult lte1 $ LTESucc lte2

lteCongMult : (k : Nat) -> LTE m n -> LTE (m * k) (n * k)
lteCongMult k lte = lteMult lte lteRefl


module Prelude.Foldable

import Builtins
import Prelude.Bool
import Prelude.Classes
import Prelude.Algebra

%access public
%default total

class Foldable (t : Type -> Type) where
  foldr : (elt -> acc -> acc) -> acc -> t elt -> acc

foldl : Foldable t => (acc -> elt -> acc) -> acc -> t elt -> acc
foldl f z t = foldr (flip (.) . flip f) id t z

concat : (Foldable t, Monoid a) => t a -> a
concat = foldr (<+>) neutral

concatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m
concatMap f = foldr ((<+>) . f) neutral

and : Foldable t => t (Lazy Bool) -> Bool
and = foldr (flip (&&)) True

or : Foldable t => t (Lazy Bool) -> Bool
or = foldr (flip (||)) False

any : Foldable t => (a -> Bool) -> t a -> Bool
any p = foldr (flip (||) . Delay . p) False

all : Foldable t => (a -> Bool) -> t a -> Bool
all p = foldr (flip (&&) . Delay . p) True

sum : (Foldable t, Num a) => t a -> a
sum = foldr (+) 0

product : (Foldable t, Num a) => t a -> a
product = foldr (*) 1

Make `and`, `or`, `any`, and `all` short-circuit from left-to-right, as is more natural.

module Prelude.Foldable

import Builtins
import Prelude.Bool
import Prelude.Classes
import Prelude.Algebra

%access public
%default total

class Foldable (t : Type -> Type) where
  foldr : (elt -> acc -> acc) -> acc -> t elt -> acc

foldl : Foldable t => (acc -> elt -> acc) -> acc -> t elt -> acc
foldl f z t = foldr (flip (.) . flip f) id t z

concat : (Foldable t, Monoid a) => t a -> a
concat = foldr (<+>) neutral

concatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m
concatMap f = foldr ((<+>) . f) neutral

and : Foldable t => t (Lazy Bool) -> Bool
and = foldl (&&) True

or : Foldable t => t (Lazy Bool) -> Bool
or = foldl (||) False

any : Foldable t => (a -> Bool) -> t a -> Bool
any p = foldl (\x => \y => x || p y) False

all : Foldable t => (a -> Bool) -> t a -> Bool
all p = foldl (\x => \y => x && p y)  True

sum : (Foldable t, Num a) => t a -> a
sum = foldr (+) 0

product : (Foldable t, Num a) => t a -> a
product = foldr (*) 1


module Decidable.Decidable

import Data.Rel
import Data.Fun

||| An n-ary relation is decidable if we can make a `Dec`
||| of its result type for each combination of inputs
public export
IsDecidable : (k : Nat) -> (ts : Vect k Type) -> Rel ts -> Type
IsDecidable k ts p = liftRel (the (Vect k Type) ts) (the (Rel ts) p) Dec

||| Interface for decidable n-ary Relations
public export
interface Decidable k ts p where
  total decide : IsDecidable k ts p

||| Given a `Decidable` n-ary relation, provides a decision procedure for
||| this relation.
decision : (ts : Vect k Type) -> (p : Rel ts) -> (Decidable k ts p) => liftRel ts p Dec
decision ts p = decide {ts} {p}

using (a : Type, x : a)
  public export
  data Given : Dec a -> Type where
    Always : Given (Yes x)

Add isYes function and friends

module Decidable.Decidable

import Data.Rel
import Data.Fun

public export
isNo : Dec a -> Bool
isNo (Yes _) = False
isNo (No _) = True

public export
isYes : Dec a -> Bool
isYes (Yes _) = True
isYes (No _) = False

||| Proof that some `Dec` is actually `Yes`
public export
data IsYes : Dec a -> Type where
  ItIsYes : IsYes (Yes prf)

public export
Uninhabited (IsYes (No contra)) where
  uninhabited ItIsYes impossible

||| Decide whether a 'Dec' is 'Yes'
public export
isItYes : (v : Dec a) -> Dec (IsYes v)
isItYes (Yes _) = Yes ItIsYes
isItYes (No _) = No absurd

||| An n-ary relation is decidable if we can make a `Dec`
||| of its result type for each combination of inputs
public export
IsDecidable : (k : Nat) -> (ts : Vect k Type) -> Rel ts -> Type
IsDecidable k ts p = liftRel (the (Vect k Type) ts) (the (Rel ts) p) Dec

||| Interface for decidable n-ary Relations
public export
interface Decidable k ts p where
  total decide : IsDecidable k ts p

||| Given a `Decidable` n-ary relation, provides a decision procedure for
||| this relation.
decision : (ts : Vect k Type) -> (p : Rel ts) -> (Decidable k ts p) => liftRel ts p Dec
decision ts p = decide {ts} {p}

using (a : Type, x : a)
  public export
  data Given : Dec a -> Type where
    Always : Given (Yes x)


module Http

data Method = POST | GET

Host : Type
Host = String

Port : Type
Port = String

HttpVersion : Type
HttpVersion = String

record Request where
  constructor MkRequest
  method  : Method
  host    : Host
  port    : Port
  version : HttpVersion

Change Port from String to Int and add some documentation

module Http

||| The HTTP Method which is either POST or GET
data Method = POST | GET

||| A String-alias for Hosts.
Host : Type
Host = String

||| Port is an alias for Int.
-- Todo: Maybe depend on the port range 0-65535
Port : Type
Port = Int

||| A type alias for HTTP Versions.
||| HttpVersion shall have the value "HTTP\1.0" or "HTTP\1.1"
HttpVersion : Type
HttpVersion = String

||| A data type for requests.
||| A request consists out of a method,
||| a host, a port and a http version.
record Request where
  constructor MkRequest
  method  : Method
  host    : Host
  port    : Port
  version : HttpVersion


module Main

mutual

  data Locked : Type where
    Start  : Locked
    Lock   : Closed -> Locked

  data Closed : Type where
    Close  : Opened -> Closed
    Unlock : Locked -> Closed

  data Opened : Type where
    Open   : Closed -> Opened

Write out the states in more consise notation.

module Main

mutual

  data Locked = Start | Lock Closed
  data Closed = Close Opened | Unlock Locked
  data Opened = Open Closed


module Data.List

%access public

using (xs : List a)
  ||| A proof that some element is found in a list
  data Elem : a -> List a -> Type where
       Here : Elem x (x :: xs)
       There : Elem x xs -> Elem x (y :: xs)

  instance Uninhabited (Elem {a} x []) where
       uninhabited Here impossible
       uninhabited (There p) impossible

  private
  mkNo : ((x = y) -> _|_) -> (Elem x xs -> _|_) -> Elem x (y :: xs) -> _|_
  mkNo f g Here = f refl
  mkNo f g (There x) = g x

  isElem : DecEq a => (x : a) -> (xs : List a) -> Dec (Elem x xs)
  isElem x [] = No absurd
  isElem x (y :: xs) with (decEq x y)
    isElem x (x :: xs) | (Yes refl) = Yes Here
    isElem x (y :: xs) | (No contra) with (isElem x xs)
      isElem x (y :: xs) | (No contra) | (Yes prf) = Yes (There prf)
      isElem x (y :: xs) | (No contra) | (No f) = No (mkNo contra f)

Move 'mkNo' to a where

module Data.List

%access public

using (xs : List a)
  ||| A proof that some element is found in a list
  data Elem : a -> List a -> Type where
       Here : Elem x (x :: xs)
       There : Elem x xs -> Elem x (y :: xs)

  instance Uninhabited (Elem {a} x []) where
       uninhabited Here impossible
       uninhabited (There p) impossible

  isElem : DecEq a => (x : a) -> (xs : List a) -> Dec (Elem x xs)
  isElem x [] = No absurd
  isElem x (y :: xs) with (decEq x y)
    isElem x (x :: xs) | (Yes refl) = Yes Here
    isElem x (y :: xs) | (No contra) with (isElem x xs)
      isElem x (y :: xs) | (No contra) | (Yes prf) = Yes (There prf)
      isElem x (y :: xs) | (No contra) | (No f) = No (mkNo contra f)
        where
          mkNo : {xs' : List a} ->
                 ((x' = y') -> _|_) -> (Elem x' xs' -> _|_) ->
                 Elem x' (y' :: xs') -> _|_
          mkNo f g Here = f refl
          mkNo f g (There x) = g x


import Http
import Http.Uri
import Http.Error
import Http.RawResponse
import Http.Request
import Http.Response
import Data.SortedMap -- Remove after upgrading to idris 0.9.19
import Network.Socket
import System

uri : String -> Int -> String -> URI
uri host port path = MkURI "http" (MkURIAuth Nothing Nothing host port) path [] ""

toRequest : Method -> String -> Int -> String -> Request String
toRequest method host port path = MkRequest method (uri host port path) "" (fromList [("Host", host)])

processArgs : List String -> Maybe (Request String)
processArgs (_::method::host::port::path::_) =
  Just (toRequest (cast method) host (cast port) path)
processArgs (_::method::host::path::_) = Just (toRequest (cast method) host 80 path)
processArgs _ = Nothing

partial
main : IO ()
main =
  case processArgs !getArgs of
    Just req =>
      case !(httpRequest req) of
        Left err => print err >>= \_ => putStr "\n"
        Right res => do
          putStrLn "Response status:"
          print (responseStatus res)
          putStr "\n\n"

          putStrLn "Headers Received:"
          traverse (\x => do print x; putStr "\n") (Data.SortedMap.toList $ responseHeaders res)
          putStr "\n\n"

          putStrLn "Body:"
          print (responseBody res)
          putStr "\n\n"
    Nothing => putStrLn "Usage: ./simple method host [port] path"

Simplify code of simple example

import Http
import Http.Uri
import Http.Error
import Http.RawResponse
import Http.Request
import Http.Response
import Data.SortedMap -- Remove after upgrading to idris 0.9.19
import Network.Socket
import System

processArgs : List String -> Maybe (Host, Port, String)
processArgs (_::host::port::path::_) =
  Just (host, (cast port), path)
processArgs (_::host::path::_) = Just (host, 80, path)
processArgs _ = Nothing

partial
main : IO ()
main =
  case processArgs !getArgs of
    Just (host, port, path) =>
      case !(simpleHttp host port path) of
        Left err => print err >>= \_ => putStr "\n"
        Right res => do
          putStrLn "Response status:"
          print (responseStatus res)
          putStr "\n\n"

          putStrLn "Headers Received:"
          traverse (\x => do print x; putStr "\n") (Data.SortedMap.toList $ responseHeaders res)
          putStr "\n\n"

          putStrLn "Body:"
          print (responseBody res)
          putStr "\n\n"
    Nothing => putStrLn "Usage: ./simple host [port] path"


module Main
import Data.List
%language TypeProviders
%default total

data Choice : List a -> Type
where Choose : (x : a) ->
               {xs : List a} ->
               {auto p : Elem x xs} ->
               Choice xs

transitions : List (String, String)
transitions =
  [("locked", "closed"),
  ("closed", "locked"),
  ("closed", "closed"),
  ("closed", "opened")]

Transition : Type
Transition = Choice transitions

single : Transition -> (String, String)
single (Choose x) = x

data Route : Type -> (a, a) -> Type
where
  Begin : Route () (s, s)
  Then  : (t : Transition) -> Route () (single t)
  (>>=) : Route a (s1, s2) -> (a -> Route b (s2, s3)) -> Route b (s1, s3)

door : Route () ("locked", "opened")
door = do Begin
--        Then $ Choose ("locked", "opened") -> Won't compile as it's not a valid transition.
          Then $ Choose ("locked", "closed")
          Then $ Choose ("closed", "closed")
          Then $ Choose ("closed", "opened")

Add comments to explain the process of creating the FSM.

module Main
import Data.List
%language TypeProviders
%default total

-- A list of valid steps that could eventually come from a type provider.
steps : List (String, String)
steps =
  [("locked", "closed"),
  ("closed", "locked"),
  ("closed", "closed"),
  ("closed", "opened")]

-- A Choice is a type representing a discrete set of choices.
data Choice : List a -> Type
where Choose : (x : a) ->
               {xs : List a} ->
               {auto p : Elem x xs} ->
               Choice xs

-- A choice between the valid steps.
Step : Type
Step = Choice steps

-- Deconstruct a step into its states.
single : Step -> (String, String)
single (Choose x) = x

-- Use the allowed steps to define a finite state machine type.
data Route : Type -> (a, a) -> Type
where
  Begin : Route () (s, s)
  Then  : (step : Step) -> Route () (single step)
  (>>=) : Route a (s1, s2) -> (a -> Route b (s2, s3)) -> Route b (s1, s3)

-- An example implementation of our finite state machine.
door : Route () ("locked", "opened")
door = do Begin
--        Then $ Choose ("locked", "opened") -> Won't compile as it's not a valid step.
          Then $ Choose ("locked", "closed")
          Then $ Choose ("closed", "closed")
          Then $ Choose ("closed", "opened")


import Http
import Http.Uri
import Http.RawResponse
import Http.Request
import Http.Response
import Network.Socket
import System

uri : String -> Int -> String -> URI
uri host port path = MkURI "http" (MkURIAuth Nothing Nothing host port) path [] ""

toRequest : Method -> String -> Int -> String -> Request
toRequest method host port path = MkRequest method (uri host port path) [] [("Host", host)]

processArgs : List String -> Maybe Request
processArgs (_::method::host::path::_) = Just (toRequest (cast method) host 80 path)
processArgs (_::method::host::port::path::_) =
  Just (toRequest (cast method) host (cast port) path)
processArgs _ = Nothing

partial
main : IO ()
main = do
  args <- getArgs
  case processArgs args of
    Just req => do
      res <- sendRequest req
      case res of
        Left err => print err >>= \_ => putStr "\n"
        Right s => print (responseStatus s) >>= \_ => putStr "\n"
    Nothing => putStrLn "Usage: ./simple method host [port] path"

Fix bug when not passing port number

import Http
import Http.Uri
import Http.RawResponse
import Http.Request
import Http.Response
import Network.Socket
import System

uri : String -> Int -> String -> URI
uri host port path = MkURI "http" (MkURIAuth Nothing Nothing host port) path [] ""

toRequest : Method -> String -> Int -> String -> Request
toRequest method host port path = MkRequest method (uri host port path) [] [("Host", host)]

processArgs : List String -> Maybe Request
processArgs (_::method::host::port::path::_) =
  Just (toRequest (cast method) host (cast port) path)
processArgs (_::method::host::path::_) = Just (toRequest (cast method) host 80 path)
processArgs _ = Nothing

partial
main : IO ()
main = do
  args <- getArgs
  case processArgs args of
    Just req => do
      res <- sendRequest req
      case res of
        Left err => print err >>= \_ => putStr "\n"
        Right s => print (responseStatus s) >>= \_ => putStr "\n"
    Nothing => putStrLn "Usage: ./simple method host [port] path"


module Prelude.Functor

import Prelude.Basics

||| Functors
||| @ f the action of the functor on objects
class Functor (f : Type -> Type) where
    ||| The action of the functor on morphisms
    ||| @ f the functor
    ||| @ m the morphism
    map : (m : a -> b) -> f a -> f b

class Functor f => VerifiedFunctor (f : Type -> Type) where
  functorIdentity : {a : Type} -> (x : f a) -> map id x = id x
  functorComposition : {a : Type} -> {b : Type} -> (x : f a) ->
                       (g1 : a -> b) -> (g2 : b -> c) ->
                       map (g2 . g1) x = (map g2 . map g1) x

instance Functor id where
    map f a = f a

Add <$> as an alias for map

module Prelude.Functor

import Prelude.Basics

||| Functors
||| @ f the action of the functor on objects
class Functor (f : Type -> Type) where
    ||| The action of the functor on morphisms
    ||| @ f the functor
    ||| @ m the morphism
    map : (m : a -> b) -> f a -> f b

infixl 4 <$>

||| An infix alias for `map`: the action of a functor on morphisms.
||| @ f the functor
||| @ m the morphism
(<$>) : Functor f => (m : a -> b) -> f a -> f b
m <$> x = map m x

class Functor f => VerifiedFunctor (f : Type -> Type) where
  functorIdentity : {a : Type} -> (x : f a) -> map id x = id x
  functorComposition : {a : Type} -> {b : Type} -> (x : f a) ->
                       (g1 : a -> b) -> (g2 : b -> c) ->
                       map (g2 . g1) x = (map g2 . map g1) x

instance Functor id where
    map f a = f a


module Uninhabited

class Uninhabited t where
  total uninhabited : t -> _|_

instance Uninhabited (Fin Z) where
  uninhabited fZ impossible
  uninhabited (fS f) impossible

instance Uninhabited (Z = S n) where
  uninhabited refl impossible

Add a function for dealing with absurdity

module Uninhabited

class Uninhabited t where
  total uninhabited : t -> _|_

instance Uninhabited (Fin Z) where
  uninhabited fZ impossible
  uninhabited (fS f) impossible

instance Uninhabited (Z = S n) where
  uninhabited refl impossible

-- | Use an absurd assumption to discharge a proof obligation
absurd : Uninhabited t => t -> a
absurd t = FalseElim (uninhabited t)


%default total

data TTy : Nat -> Nat -> Nat -> Nat -> Bool -> Type where

  TA : TTy p1 r1 i1 i2 False ->
       TTy i1 i2 i1 u2 False ->
       TTy i1 i2 p2 b1 b2    ->
       TTy p1 r1 p1 i2 False

  TB : TTy v1 r1 v2 r2 bt ->
       TTy v1 r1 v1 r2 (be && bt)

  TC : TTy p1 r1 v2 r2 False ->
       TTy v2 r2 v3 r3 b2    ->
       TTy p1 r1 v3 r3 b2

n : Nat -> Nat
n = (+ 2)

showInd : (indent : Nat) -> TTy p1 r1 v3 r3 br -> String
showInd i (TA x1 x2 x3) = if False
                            then (if False then show' i else show' i)
                            else showInd (n i) x1 ++ show' (n i)
                            where
                              show' : Nat -> String
                              show' i = showInd (n i) x3 ++ if False then "" else showInd (n i) x2
showInd i (TB x) = showInd (n i) x ++ if False then "" else showInd (n i) x
showInd i (TC x y) = if False then showInd i y else showInd i x ++ showInd i y

Remove whitespace in test file


interface Queue (q: Type -> Type) where
  empty : q a
  isEmpty : q a -> Bool
  snoc : q a -> a -> q a
  head : q a -> a
  tail : q a -> q a

data CatList : (Type -> Type) -> Type -> Type where
  E : CatList q a
  C : {0 q : Type -> Type} -> a -> q (Lazy (CatList q a)) -> CatList q a

-- %logging 5
partial
link : (Queue q) => CatList q a -> Lazy (CatList q a) -> CatList q a
link E s = s -- Just to satisfy totality for now.
link (C x xs) s = C x (snoc xs s) -- can't solve constraint between
                                  -- Lazy (CatList q a) and CatList q a
-- %logging 0

Remove my debugging noise from test case

interface Queue (q: Type -> Type) where
  empty : q a
  isEmpty : q a -> Bool
  snoc : q a -> a -> q a
  head : q a -> a
  tail : q a -> q a

data CatList : (Type -> Type) -> Type -> Type where
  E : CatList q a
  C : {0 q : Type -> Type} -> a -> q (Lazy (CatList q a)) -> CatList q a

link : (Queue q) => CatList q a -> Lazy (CatList q a) -> CatList q a
link E s = s -- Just to satisfy totality for now.
link (C x xs) s = C x (snoc xs s)


module IR.Layout

import IR
import IR.StackSet

%default total

column : Rectangle -> (n : Nat) -> Vect n Rectangle
column r n = column' n r n
  where column' _ _ Z = []
        column' n (MkRectangle x y w h) (S m) =
          let w' = w / fromInteger (toIntegerNat n)
          in MkRectangle (x + w' * fromInteger (toIntegerNat m)) y w' h :: column' n r m

fullLayout : LayoutF wid
fullLayout rect s = zip (integrate s) (replicate (stackLength s) rect)

columnLayout : LayoutF wid
columnLayout rect s = zip (integrate s) (column rect (stackLength s))

mirrorLayout : LayoutF wid -> LayoutF wid
mirrorLayout l (MkRectangle x' y' w' h') s = map (\(wid, MkRectangle x y w h) => (wid, MkRectangle ((y - y') / h' * w' + x') ((x - x') / w' * h' + y') (h / h' * w') (w / w' * h'))) (l (MkRectangle x' y' w' h') s)

single : LayoutF wid -> Layout wid
single l = x
  where x = MkLayout l x

choose : Vect (S n) (LayoutF wid) -> Layout wid
choose {n} (x::xs) =
  let xs' : Vect (S n) (LayoutF wid) = rewrite plusCommutative 1 n in xs ++ [x]
  in MkLayout x (choose xs')

Fix compilation error with newer Idris

module IR.Layout

import IR
import IR.StackSet

%default total

column : Rectangle -> (n : Nat) -> Vect n Rectangle
column r n = column' n r n
  where column' _ _ Z = []
        column' n (MkRectangle x y w h) (S m) =
          let w' = w / fromInteger (toIntegerNat n)
          in MkRectangle (x + w' * fromInteger (toIntegerNat m)) y w' h :: column' n r m

fullLayout : LayoutF wid
fullLayout rect s = zip (integrate s) (replicate (stackLength s) rect)

columnLayout : LayoutF wid
columnLayout rect s = zip (integrate s) (column rect (stackLength s))

mirrorLayout : LayoutF wid -> LayoutF wid
mirrorLayout l (MkRectangle x' y' w' h') s = map (\(wid, MkRectangle x y w h) => (wid, MkRectangle ((y - y') / h' * w' + x') ((x - x') / w' * h' + y') (h / h' * w') (w / w' * h'))) (l (MkRectangle x' y' w' h') s)

single : LayoutF wid -> Layout wid
single l = x
  where x = MkLayout l x

choose : Vect (S n) (LayoutF wid) -> Layout wid
choose {n} {wid} (x::xs) =
  let xs' : Vect (S n) (LayoutF wid) = rewrite plusCommutative 1 n in xs ++ [x]
  in MkLayout x (choose xs')


module Data.String.Iterator

%default total

export
data StringIterator : Type where [external]

%foreign
  "scheme:blodwen-string-iterator-new"
export
fromString : String -> StringIterator

%foreign
  "scheme:blodwen-string-iterator-next"
export
uncons : StringIterator -> Maybe (Char, StringIterator)

covering export
foldl : (a -> Char -> a) -> a -> String -> a
foldl f acc = loop acc . fromString
  where
    loop : a -> StringIterator -> a
    loop acc it =
      case uncons it of
        Nothing => acc
        Just (ch, it') => loop (f acc ch) it'

Add a missing `covering` annotation.

module Data.String.Iterator

%default total

export
data StringIterator : Type where [external]

%foreign
  "scheme:blodwen-string-iterator-new"
export
fromString : String -> StringIterator

%foreign
  "scheme:blodwen-string-iterator-next"
export
uncons : StringIterator -> Maybe (Char, StringIterator)

covering export
foldl : (a -> Char -> a) -> a -> String -> a
foldl f acc = loop acc . fromString
  where
    covering
    loop : a -> StringIterator -> a
    loop acc it =
      case uncons it of
        Nothing => acc
        Just (ch, it') => loop (f acc ch) it'


module Control.Isomorphism.Primitives

import Control.Isomorphism
import Data.ZZ

%default total
%access public

-- This module contains isomorphisms between convenient inductive types and
-- Idris primitives.  Because primitives lack a convenient structure, these
-- arguments typically end with "really_believe_me". This is why they are in a
-- separate module.

integerIsoZZ : Iso Integer ZZ
integerIsoZZ = MkIso toZZ fromZZ fromToZZ toFromZZ
  where toZZ : Integer -> ZZ
        toZZ n = cast n

        fromZZ : ZZ -> Integer
        fromZZ n = cast n

        toFromZZ : (n : Integer) -> fromZZ (toZZ n) = n
        toFromZZ n = really_believe_me {a = n=n} {b = fromZZ (toZZ n) = n} refl

        fromToZZ : (n : ZZ) -> toZZ (fromZZ n) = n
        fromToZZ n = really_believe_me {a = n=n} {b = toZZ (fromZZ n) = n} refl

Add iso between String and List Char

module Control.Isomorphism.Primitives

import Control.Isomorphism
import Data.ZZ

%default total
%access public

-- This module contains isomorphisms between convenient inductive types and
-- Idris primitives.  Because primitives lack a convenient structure, these
-- arguments typically end with "really_believe_me". This is why they are in a
-- separate module.

integerIsoZZ : Iso Integer ZZ
integerIsoZZ = MkIso toZZ fromZZ fromToZZ toFromZZ
  where toZZ : Integer -> ZZ
        toZZ n = cast n

        fromZZ : ZZ -> Integer
        fromZZ n = cast n

        toFromZZ : (n : Integer) -> fromZZ (toZZ n) = n
        toFromZZ n = really_believe_me {a = n=n} {b = fromZZ (toZZ n) = n} refl

        fromToZZ : (n : ZZ) -> toZZ (fromZZ n) = n
        fromToZZ n = really_believe_me {a = n=n} {b = toZZ (fromZZ n) = n} refl

packUnpackIso : Iso (List Char) String
packUnpackIso = MkIso pack
                      unpack
                      (\str => really_believe_me {a = str=str} {b = pack (unpack str) = str} refl)
                      (\cs  => really_believe_me {a = cs=cs}   {b = unpack (pack cs) = cs}   refl)


module Prelude.Bool

import Builtins

||| Boolean Data Type
data Bool = False | True

||| The underlying implementation of the if ... then ... else ... syntax
||| @ b the condition on the if
||| @ t the value if b is true
||| @ e the falue if b is false
boolElim : (b : Bool) -> (t : Lazy a) -> (e : Lazy a) -> a
boolElim True  t e = t
boolElim False t e = e

||| Defines a predicate on Bool which guarantees that the value is true.
data so : Bool -> Type where oh : so True

-- Syntactic sugar for boolean elimination.
syntax if [test] then [t] else [e] = boolElim test (Delay t) (Delay e)

-- Boolean Operator Precedence
infixl 4 &&, ||

||| Boolean OR
(||) : Bool -> Bool -> Bool
(||) False x = x
(||) True _  = True

||| Boolean AND
(&&) : Bool -> Bool -> Bool
(&&) True x  = x
(&&) False _ = False

||| Boolean NOT
not : Bool -> Bool
not True = False
not False = True

Add Uninhabited instances for so False

module Prelude.Bool

import Builtins

import Prelude.Uninhabited

||| Boolean Data Type
data Bool = False | True

||| The underlying implementation of the if ... then ... else ... syntax
||| @ b the condition on the if
||| @ t the value if b is true
||| @ e the falue if b is false
boolElim : (b : Bool) -> (t : Lazy a) -> (e : Lazy a) -> a
boolElim True  t e = t
boolElim False t e = e

||| Defines a predicate on Bool which guarantees that the value is true.
data so : Bool -> Type where oh : so True

instance Uninhabited (so False) where
  uninhabited oh impossible

-- Syntactic sugar for boolean elimination.
syntax if [test] then [t] else [e] = boolElim test (Delay t) (Delay e)

-- Boolean Operator Precedence
infixl 4 &&, ||

||| Boolean OR
(||) : Bool -> Bool -> Bool
(||) False x = x
(||) True _  = True

||| Boolean AND
(&&) : Bool -> Bool -> Bool
(&&) True x  = x
(&&) False _ = False

||| Boolean NOT
not : Bool -> Bool
not True = False
not False = True


module Http

||| The HTTP Method which is either POST or GET
data Method = POST | GET

||| A String-alias for Hosts.
Host : Type
Host = String

||| Port is an alias for Int.
-- Todo: Maybe depend on the port range 0-65535
Port : Type
Port = Int

||| A type alias for HTTP Versions.
||| HttpVersion shall have the value "HTTP\1.0" or "HTTP\1.1"
HttpVersion : Type
HttpVersion = String

||| A data type for requests.
||| A request consists out of a method,
||| a host, a port and a http version.
record Request where
  constructor MkRequest
  method  : Method
  host    : Host
  port    : Port
  version : HttpVersion

Add path and query to Request

module Http

||| The HTTP Method which is either POST or GET
data Method = POST | GET

||| A String-alias for Hosts.
Host : Type
Host = String

||| Port is an alias for Int.
-- Todo: Maybe depend on the port range 0-65535
Port : Type
Port = Int

||| A type alias for HTTP Versions.
||| HttpVersion shall have the value "HTTP/1.0" or "HTTP/1.1"
HttpVersion : Type
HttpVersion = String

||| A data type for requests.
||| A request consists out of a method,
||| a host, a port, a path, a query and a http version.
record Request where
  constructor MkRequest
  ||| The requests method. Either POST or GET
  method  : Method
  ||| The Host to send the request to
  host    : Host
  port    : Port
  ||| The path that is requested. "/index.html" for example.
  path    : String
  ||| A list of query tuples.
  ||| Setting query to [("v", "1.0")] will append "?v=1.0" to the path
  query   : q ** Vect q (String, String)
  ||| The version of the HTTP Request.
  version : HttpVersion


module Test

import Provider

import Database
import Queries

%language TypeProviders

%link C "sqlite3api.o"
%include C "sqlite3api.h"
%lib C "sqlite3"

%provide (db : DB "test.sqlite") with run (getSchemas "test.sqlite")

foos : Query db ["foo":::INTEGER]
foos = SELECT (["foo":::INTEGER]) FROM "test" WHERE (Col "foo" == Col "foo")

people : Query db ["name":::TEXT]
people = SELECT ["name":::TEXT] FROM "people" WHERE 1

transit : Query db ["name":::TEXT, "wheels":::INTEGER]
transit = SELECT ["name":::TEXT, "wheels":::INTEGER]
          FROM "people" * "transport"
          WHERE Col "name" == Col "owner"

printRes : Query db s -> IO ()
printRes q = do res <- runInit [()] (query q)
                case res of
                  Left err => putStrLn (show err)
                  Right table => putStrLn (showTable _ table)
namespace Main
  main : IO ()
  main = do printRes foos
            printRes people
            printRes transit
            putStrLn "ok"

Add spaces for better overview when doing talks

module Test

import Provider

import Database
import Queries
import ErrorHandlers

%language TypeProviders

%link C "sqlite3api.o"
%include C "sqlite3api.h"
%lib C "sqlite3"

%provide (db : DB "test.sqlite") with run (getSchemas "test.sqlite")

foos : Query db ["foo":::INTEGER]
foos = SELECT (["foo":::INTEGER]) FROM "test" WHERE (Col "foo" == Col "foo")

people : Query db ["name":::TEXT]
people = SELECT ["name":::TEXT] FROM "people" WHERE 1

transit : Query db ["name":::TEXT, "age":::NULLABLE INTEGER, "wheels":::INTEGER, "description" ::: TEXT]
transit = SELECT ["name":::TEXT, "age":::NULLABLE INTEGER, "wheels":::INTEGER, "description":::TEXT]
          FROM "people" * "transport"
          WHERE Col "name" == Col "owner"

printRes : Query db s -> IO ()
printRes q = do res <- runInit [()] (query q)
                case res of
                  Left err => putStrLn (show err)
                  Right table => putStrLn (showTable _ table)
namespace Main
  main : IO ()
  main = do printRes foos
            printRes people
            printRes transit
            putStrLn "ok"

-- -}
-- -}
-- -}
-- -}

-- Local Variables:
-- idris-packages: ("lightyear" "sqlite" "neweffects")
-- End:


module Python.Lib.Threading

import Python
import Python.Prim
import Python.Exceptions

import Python.Lib.Queue

%default total
%access public

Thread : Signature
Thread f = case f of
  "start" => [] ~~> ()
  "join"  => [] ~~> ()
  _ => Object f

Threading : Signature
Threading f = case f of
  -- the first arg must always be Nothing, according to Python spec
  "Thread" => [Maybe (), [] ~> ()] ~~> Obj Thread
  _ => Module f

import_ : PIO $ Obj Threading
import_ = importModule "threading"

||| Fork a side thread. The thread will send its result
||| through the queue that is returned by this function.
forkPIO : PIO a -> PIO (Obj $ Queue a)
forkPIO {a = a} work = do
    queue <- Queue.import_ /: "Queue" $: [Erase a, Just 1]
    thread <- Threading.import_ /: "Thread" $: [Nothing, marshalPIO $ worker queue]
    thread /. "start" $. []

    return queue
  where
    worker : (Obj $ Queue a) -> PIO ()
    worker queue = do
      result <- work
      queue /. "put" $. [result]

||| Wait for the result of a side thread.
wait : Obj (Queue a) -> PIO a
wait q = q /. "get" $. [1]

Use Maybe void in threading.

module Python.Lib.Threading

import Python
import Python.Prim
import Python.Exceptions

import Python.Lib.Queue

%default total
%access public

Thread : Signature
Thread f = case f of
  "start" => [] ~~> ()
  "join"  => [] ~~> ()
  _ => Object f

Threading : Signature
Threading f = case f of
  -- the first arg must always be Nothing, according to Python spec
  "Thread" => [Maybe Void, [] ~> ()] ~~> Obj Thread
  _ => Module f

import_ : PIO $ Obj Threading
import_ = importModule "threading"

||| Fork a side thread. The thread will send its result
||| through the queue that is returned by this function.
forkPIO : PIO a -> PIO (Obj $ Queue a)
forkPIO {a = a} work = do
    queue <- Queue.import_ /: "Queue" $: [Erase a, Just 1]
    thread <- Threading.import_ /: "Thread" $: [Nothing, marshalPIO $ worker queue]
    thread /. "start" $. []

    return queue
  where
    worker : (Obj $ Queue a) -> PIO ()
    worker queue = do
      result <- work
      queue /. "put" $. [result]

||| Wait for the result of a side thread.
wait : Obj (Queue a) -> PIO a
wait q = q /. "get" $. [1]


module Http.Response

import Data.Vect
import Http.RawResponse

%access public

record ResponseStatus where
  constructor MkResponseStatus
  responseStatusVersion : String
  responseStatusCode : String  -- TODO: Int
  responseStatusComment : String

instance Show ResponseStatus where
  show (MkResponseStatus ver code cmt) =
    "ResponseStatus " ++ ver ++ " " ++ code ++ " " ++ cmt

responseStatus : RawResponse String -> Maybe ResponseStatus
responseStatus (MkRawResponse r) with (lines r)
  | (x :: _) with (words x)
                | (_ :: _ :: []) = Nothing
                | (ver :: code :: cmt) = Just $
                    MkResponseStatus ver code (unwords cmt)
                | _ = Nothing
  | [] = Nothing

Make it use the constructor name

module Http.Response

import Data.Vect
import Http.RawResponse

%access public

record ResponseStatus where
  constructor MkResponseStatus
  responseStatusVersion : String
  responseStatusCode : String  -- TODO: Int
  responseStatusComment : String

instance Show ResponseStatus where
  show (MkResponseStatus ver code cmt) =
    "MkResponseStatus " ++ ver ++ " " ++ code ++ " " ++ cmt

responseStatus : RawResponse String -> Maybe ResponseStatus
responseStatus (MkRawResponse r) with (lines r)
  | (x :: _) with (words x)
                | (_ :: _ :: []) = Nothing
                | (ver :: code :: cmt) = Just $
                    MkResponseStatus ver code (unwords cmt)
                | _ = Nothing
  | [] = Nothing


module Main

mutual

  data Locked = Start | Lock Closed
  data Closed = Close Opened | Unlock Locked
  data Opened = Open Closed

Set a combination that needs to match for unlocking.

module Main

mutual

  data Locked : Nat -> Type where
    Start  : (code : Nat) -> Locked code
    Lock   : (code : Nat) -> Closed -> Locked code

  data Closed : Type where
    Unlock : (code : Nat) -> Locked code -> Closed

  data Opened = Open Closed


module Lightyear.String_
-- Reserved words cannot be used in module names.
-- Unfortunately, String is a reserved word.

import Lightyear.Core
import Lightyear.Combinators

%access public

private
uncons : String -> Maybe (Char, String)
uncons s with (strM s)
  uncons ""             | StrNil       = Nothing
  uncons (strCons x xs) | StrCons x xs = Just (x, xs)

infixl 0 <?->
private
(<?->) : Monad m => ParserT m str a -> String -> ParserT m str a
p <?-> msg = p <??> (Lib, msg)

satisfy : Monad m => (Char -> Bool) -> ParserT m String Char
satisfy = satisfy' (St uncons)

char : Monad m => Char -> ParserT m String ()
char c = skip (satisfy (== c)) <?-> "character '" ++ c2s c ++ "'"

string : Monad m => String -> ParserT m String ()
string s = traverse_ char (unpack s) <?-> "string " ++ show s

space : Monad m => ParserT m String ()
space = skip (many $ satisfy isSpace) <?-> "whitespace"

token : Monad m => String -> ParserT m String ()
token s = skip (string s) <$ space <?-> "token " ++ show s

parens : Monad m => ParserT m String a -> ParserT m String a
parens p = char '(' $> p <$ char ')' <?+> "parenthesized"

Add commonly used definitions of Parser and parse.

module Lightyear.String_
-- Reserved words cannot be used in module names.
-- Unfortunately, String is a reserved word.

import Lightyear.Core
import Lightyear.Combinators

%access public

Parser : Type -> Type
Parser = ParserT Identity String

parse : Parser a -> String -> Result String a
parse (PT f) s = let Id p = f s in p

private
uncons : String -> Maybe (Char, String)
uncons s with (strM s)
  uncons ""             | StrNil       = Nothing
  uncons (strCons x xs) | StrCons x xs = Just (x, xs)

infixl 0 <?->
private
(<?->) : Monad m => ParserT m str a -> String -> ParserT m str a
p <?-> msg = p <??> (Lib, msg)

satisfy : Monad m => (Char -> Bool) -> ParserT m String Char
satisfy = satisfy' (St uncons)

char : Monad m => Char -> ParserT m String ()
char c = skip (satisfy (== c)) <?-> "character '" ++ c2s c ++ "'"

string : Monad m => String -> ParserT m String ()
string s = traverse_ char (unpack s) <?-> "string " ++ show s

space : Monad m => ParserT m String ()
space = skip (many $ satisfy isSpace) <?-> "whitespace"

token : Monad m => String -> ParserT m String ()
token s = skip (string s) <$ space <?-> "token " ++ show s

parens : Monad m => ParserT m String a -> ParserT m String a
parens p = char '(' $> p <$ char ')' <?+> "parenthesized"


module Http

import public Http.Uri
import public Http.Error
import public Http.RawResponse
import public Http.Request
import public Http.Response
import public Data.SortedMap
import public Data.Vect
import public Network.Socket

%access export

private
sendRequest : Request a -> IO (Either HttpError (RawResponse String))
sendRequest req = do
    Right sock <- socket AF_INET Stream 0 | Left err => pure (Left $ HttpSocketError err)
    0 <- connect sock (Hostname host) port | err => pure (Left $ HttpSocketError err)
    Right _ <- send sock (resolveRequest req) | Left err => pure (Left $ HttpSocketError err)
    Right (str, _) <- recv sock 65536 | Left err => pure (Left $ HttpSocketError err)
    pure (Right (MkRawResponse str))
  where
    host : String
    host = uriHost . uriAuth . uri $ req

    port : Int
    port = uriPort . uriAuth . uri $ req

httpRequest : Request a -> IO (Either HttpError (Response String))
httpRequest req = pure $ !(sendRequest req) >>= parseResponse

simpleHttp : Host -> Port -> (path : String) -> IO (Either HttpError (Response String))
simpleHttp host port path = do
  let headers = Data.SortedMap.fromList [("Host", host ++ ":" ++ show port)]
  repl <- sendRequest (MkRequest GET (MkURI "http" (MkURIAuth Nothing Nothing host port) path [] "") "" headers)
  pure (repl >>= parseResponse)

Read until EOF, not just one packet

module Http

import public Http.Uri
import public Http.Error
import public Http.RawResponse
import public Http.Request
import public Http.Response
import public Data.SortedMap
import public Data.Vect
import public Network.Socket

%access export

||| Loop until EOF.
||| TODO: Actually check for EOF instead of "all errors"
private
readResp : Socket -> String -> IO String
readResp sock buf = do
  Right (str, t) <- recv sock 65536 | Left err => pure buf
  readResp sock (buf ++ str)

private
sendRequest : Request a -> IO (Either HttpError (RawResponse String))
sendRequest req = do
    Right sock <- socket AF_INET Stream 0 | Left err => pure (Left $ HttpSocketError err)
    0 <- connect sock (Hostname host) port | err => pure (Left $ HttpSocketError err)
    Right _ <- send sock (resolveRequest req) | Left err => pure (Left $ HttpSocketError err)
    str <- readResp sock ""
    pure (Right (MkRawResponse str))
  where
    host : String
    host = uriHost . uriAuth . uri $ req

    port : Int
    port = uriPort . uriAuth . uri $ req

httpRequest : Request a -> IO (Either HttpError (Response String))
httpRequest req = pure $ !(sendRequest req) >>= parseResponse

simpleHttp : Host -> Port -> (path : String) -> IO (Either HttpError (Response String))
simpleHttp host port path = do
  let headers = Data.SortedMap.fromList [("Host", host), ("Connection", "close")]
  repl <- sendRequest (MkRequest GET (MkURI "http" (MkURIAuth Nothing Nothing host port) path [] "") "" headers)
  pure (repl >>= parseResponse)


||| Until Idris2 starts supporting the 'syntax' keyword, here's a
||| poor-man's equational reasoning
module Syntax.PreorderReasoning

infixl 0  ~~
prefix 1  |~
infix  1  ...

|||Slightly nicer syntax for justifying equations:
|||```
||| |~ a
||| ~~ b ...( justification )
|||```
|||and we can think of the `...( justification )` as ASCII art for a thought bubble.
public export
(...) : (x : a) -> (y ~=~ x) -> (z : a ** y ~=~ z)
(...) x pf = (x ** pf)

public export
data FastDerivation : (x : a) -> (y : b) -> Type where
  (|~) : (x : a) -> FastDerivation x x
  (~~) : FastDerivation x y -> (step : (z : c ** y ~=~ z)) -> FastDerivation x (fst step)

public export
Calc : {x : a} -> {y : b} -> FastDerivation x y -> x ~=~ y
Calc (|~ x) = Refl
Calc {y} ((~~) {z=_} {y=_} der (_ ** Refl)) = Calc der

{- -- requires import Data.Nat
0
example : (x : Nat) -> (x + 1) + 0 = 1 + x
example x =
  Calc $
   |~ (x + 1) + 0
   ~~ x+1  ...( plusZeroRightNeutral $ x + 1 )
   ~~ 1+x  ...( plusCommutative x 1          )
-}

Remove bindning to `y` as no longer necessary

||| Until Idris2 starts supporting the 'syntax' keyword, here's a
||| poor-man's equational reasoning
module Syntax.PreorderReasoning

infixl 0  ~~
prefix 1  |~
infix  1  ...

|||Slightly nicer syntax for justifying equations:
|||```
||| |~ a
||| ~~ b ...( justification )
|||```
|||and we can think of the `...( justification )` as ASCII art for a thought bubble.
public export
(...) : (x : a) -> (y ~=~ x) -> (z : a ** y ~=~ z)
(...) x pf = (x ** pf)

public export
data FastDerivation : (x : a) -> (y : b) -> Type where
  (|~) : (x : a) -> FastDerivation x x
  (~~) : FastDerivation x y -> (step : (z : c ** y ~=~ z)) -> FastDerivation x (fst step)

public export
Calc : {x : a} -> {y : b} -> FastDerivation x y -> x ~=~ y
Calc (|~ x) = Refl
Calc ((~~) {z=_} {y=_} der (_ ** Refl)) = Calc der

{- -- requires import Data.Nat
0
example : (x : Nat) -> (x + 1) + 0 = 1 + x
example x =
  Calc $
   |~ (x + 1) + 0
   ~~ x+1  ...( plusZeroRightNeutral $ x + 1 )
   ~~ 1+x  ...( plusCommutative x 1          )
-}


module Prelude.Foldable

import Builtins
import Prelude.Bool
import Prelude.Classes
import Prelude.Algebra

%access public
%default total

class Foldable (t : Type -> Type) where
  foldr : (elt -> acc -> acc) -> acc -> t elt -> acc

foldl : Foldable t => (acc -> elt -> acc) -> acc -> t elt -> acc
foldl f z t = foldr (flip (.) . flip f) id t z

concat : (Foldable t, Monoid a) => t a -> a
concat = foldr (<+>) neutral

concatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m
concatMap f = foldr ((<+>) . f) neutral

and : Foldable t => t (Lazy Bool) -> Bool
and = foldr (flip (&&)) True

or : Foldable t => t (Lazy Bool) -> Bool
or = foldr (flip (||)) False

any : Foldable t => (a -> Bool) -> t a -> Bool
any p = foldr (flip (||) . Delay . p) False

all : Foldable t => (a -> Bool) -> t a -> Bool
all p = foldr (flip (&&) . Delay . p) True

sum : (Foldable t, Num a) => t a -> a
sum = foldr (+) 0

product : (Foldable t, Num a) => t a -> a
product = foldr (*) 1

Make `and`, `or`, `any`, and `all` short-circuit from left-to-right, as is more natural.

module Prelude.Foldable

import Builtins
import Prelude.Bool
import Prelude.Classes
import Prelude.Algebra

%access public
%default total

class Foldable (t : Type -> Type) where
  foldr : (elt -> acc -> acc) -> acc -> t elt -> acc

foldl : Foldable t => (acc -> elt -> acc) -> acc -> t elt -> acc
foldl f z t = foldr (flip (.) . flip f) id t z

concat : (Foldable t, Monoid a) => t a -> a
concat = foldr (<+>) neutral

concatMap : (Foldable t, Monoid m) => (a -> m) -> t a -> m
concatMap f = foldr ((<+>) . f) neutral

and : Foldable t => t (Lazy Bool) -> Bool
and = foldl (&&) True

or : Foldable t => t (Lazy Bool) -> Bool
or = foldl (||) False

any : Foldable t => (a -> Bool) -> t a -> Bool
any p = foldl (\x => \y => x || p y) False

all : Foldable t => (a -> Bool) -> t a -> Bool
all p = foldl (\x => \y => x && p y)  True

sum : (Foldable t, Num a) => t a -> a
sum = foldr (+) 0

product : (Foldable t, Num a) => t a -> a
product = foldr (*) 1


module Parser

import Lightyear.Core
import Lightyear.Strings
import Lightyear.Combinators
import Queries

sqltype : Parser SQLiteType
sqltype = the (Parser _) $
          (do token "int"  <|> token "int"
              pure INTEGER)
      <|> (do token "text" <|> token "string"
              pure TEXT)
      <|> (do token "real" <|> token "float"
              pure REAL)

name : Parser String
name = do n <- many (satisfy (\c => c >= 'a' && c <= 'z'))
          return (pack n)

nullable : Parser Bool
nullable = (do token "not"
               token "null"
               return False)
       <|> return True

sqlCol : Parser Attribute
sqlCol = do n <- name
            space
            ty <- sqltype
            null <- nullable
            pure (n:::(if null then NULLABLE ty else ty))

comma : Parser ()
comma = char ','

cols : Parser Schema
cols = do cols <- sepBy sqlCol (space $> comma $> space)
          pure (toSchema cols)
  where toSchema : List Attribute -> Schema
        toSchema [] = []
        toSchema (x::xs) = x :: toSchema xs

table : Parser (String, Schema)
table = do token "create"
           token "table"
           n <- name
           space
           token "("
           cs <- cols
           space
           token ")"
           pure (n,cs)

-- Local Variables:
-- idris-packages: ("lightyear")
-- End:

Fix "int" -> "integer" to avoid double

module Parser

import Lightyear.Core
import Lightyear.Strings
import Lightyear.Combinators
import Queries

sqltype : Parser SQLiteType
sqltype = the (Parser _) $
          (do token "int"  <|> token "integer"
              pure INTEGER)
      <|> (do token "text" <|> token "string"
              pure TEXT)
      <|> (do token "real" <|> token "float"
              pure REAL)

name : Parser String
name = do n <- many (satisfy (\c => c >= 'a' && c <= 'z'))
          return (pack n)

nullable : Parser Bool
nullable = (do token "not"
               token "null"
               return False)
       <|> return True

sqlCol : Parser Attribute
sqlCol = do n <- name
            space
            ty <- sqltype
            null <- nullable
            pure (n:::(if null then NULLABLE ty else ty))

comma : Parser ()
comma = char ','

cols : Parser Schema
cols = do cols <- sepBy sqlCol (space $> comma $> space)
          pure (toSchema cols)
  where toSchema : List Attribute -> Schema
        toSchema [] = []
        toSchema (x::xs) = x :: toSchema xs

table : Parser (String, Schema)
table = do token "create"
           token "table"
           n <- name
           space
           token "("
           cs <- cols
           space
           token ")"
           pure (n,cs)

-- Local Variables:
-- idris-packages: ("lightyear")
-- End:


> module MyOrd

An alternative Ord instance for Nats, with an explicit name "myord"
for the dictionary:

> instance [myord] Ord Nat where
>    compare O (S n)     = GT
>    compare (S n) O     = LT
>    compare O O         = EQ

The @{name} syntax below gives an explicit dictionary for the compare function.
Here, we're telling it to use the "myord" dictionary. Otherwise, it'd just
use the default (unnamed) instance. Note that there can only be one unnamed
instance --- they must not overlap.

>    compare (S x) (S y) = compare @{myord} x y

> foo : List Nat
> foo = [1,4,2,8,3,7,5,6]

Sort foo using the default comparison operator:

> test1 : List Nat
> test1 = sort foo

-- which gives [1,2,3,4,5,6,7,8]

Sort foo using the alternative instance. No need for 'sortBy' and other
such functions. Hoorah!

> test2 : List Nat
> test2 = sort @{myord} foo

-- which gives [8,7,6,5,4,3,2,1]


module IR.Lens

import Control.Category

data Store s a = MkStore (s -> a) s

pos : Store s a -> s
pos (MkStore _ s) = s

peek : s -> Store s a -> a
peek s (MkStore f _) = f s

peeks : (s -> s) -> Store s a -> a
peeks f (MkStore g s) = g (f s)

data Lens a b = MkLens (a -> Store b a)

instance Category Lens where
  id = MkLens (MkStore id)
  (.) (MkLens f) (MkLens g) = MkLens (\a => case g a of
    MkStore ba b => case f b of
      MkStore cb c => MkStore (Prelude.Basics.(.) ba cb) c)

lens : (a -> b) -> (b -> a -> a) -> Lens a b
lens f g = MkLens (\a => MkStore (\b => g b a) (f a))

iso : (a -> b) -> (b -> a) -> Lens a b
iso f g = MkLens (\a => MkStore g (f a))

getL : Lens a b -> a -> b
getL (MkLens f) a = pos (f a)

setL : Lens a b -> b -> a -> a
setL (MkLens f) b = peek b . f

modL : Lens a b -> (b -> b) -> a -> a
modL (MkLens f) g = peeks g . f

infixr 0 ^$
(^$) : Lens a b -> a -> b
(^$) = getL

infixr 4 ^=
(^=) : Lens a b -> b -> a -> a
(^=) = setL

infixr 4 ^%=
(^%=) : Lens a b -> (b -> b) -> a -> a
(^%=) = modL


import Data.Vect

total
vassoc : (xs : Vect n a) -> (ys : Vect m a) -> (zs : Vect p a) ->
         xs ++ (ys ++ zs) = (xs ++ ys) ++ zs
vassoc [] ys zs = Refl
vassoc (x :: xs) ys zs
    = rewrite vassoc xs ys zs in Refl
total
vassoc' : (xs : Vect n a) -> (ys : Vect m a) -> (zs : Vect p a) ->
         xs ++ (ys ++ zs) = (xs ++ ys) ++ zs
vassoc' [] ys zs = Refl
vassoc' (x :: xs) ys zs
    = rewrite vassoc xs ys xs in Refl


module Data.List.Group

||| The groupBy function returns a list of lists such that the concatenation
||| of the list is equal to the argument, and each sublist contains only
||| elements that are equal according to the user-supplied predicate.
|||
||| ```idris example
||| groupBy (==) [1, 1, 2, 3, 3]
||| ```
|||
groupBy : (a -> a -> Bool) -> List a -> List (List a)
groupBy _ [] = []
groupBy p list@(x :: xs) =
  let (ys, zs) = span (p x) xs in
    (x :: ys) :: groupBy p (assert_smaller list zs)

||| The group function is a special case of groupBy.
|||
||| ```idris example
||| group [1, 1, 2, 3, 3]
||| ```
|||
group : Eq a => List a -> List (List a)
group = groupBy (==)


angular.module \laweasyread.controllers, []
.controller \TypeaheadCtrl, [
    \$scope, \Suggestions
    ($scope, Suggestions)->
        $scope.laws = []
        (res) <- Suggestions.get {query: '法'}
        for item in res.suggestion
            $scope.laws.push(item.law)
]

Check isSuccess before reading suggestion

angular.module \laweasyread.controllers, []
.controller \TypeaheadCtrl, [
    \$scope, \Suggestions
    ($scope, Suggestions) ->
        $scope.laws = []
        res <- Suggestions.get {query: '法'}
        if res.isSuccess
            for item in res.suggestion
                $scope.laws.push item.law
]


N = process.argv[2] || 1000
nsqrt = Math.pow N, 0.5

is_prime = []

for x from 1 to nsqrt
  for y from 1 to nsqrt
    continue if n > N
    n = 4 * (x ^ 2) + (y ^ 2)
    is_prime[n] = true if (n % 12 is 1 or n % 12 is 5)

    n = 3 * (x ^ 2) + y ^ 2
    is_prime[n] = true if n % 12 is 7

    n = 3 * (x ^ 2) - y ^ 2
    is_prime[n] = true if x > y and n % 12 == 11

primes = is_prime.map((v, k) -> v and k).filter -> it
console.log primes.length

Fix missing 2,3 from liveScript solution

N = process.argv[2] || 1000
nsqrt = Math.pow N, 0.5

is_prime = [false, false, true, true]

for x from 1 to nsqrt
  for y from 1 to nsqrt
    continue if n > N
    n = 4 * (x ^ 2) + (y ^ 2)
    is_prime[n] = true if (n % 12 is 1 or n % 12 is 5)

    n = 3 * (x ^ 2) + y ^ 2
    is_prime[n] = true if n % 12 is 7

    n = 3 * (x ^ 2) - y ^ 2
    is_prime[n] = true if x > y and n % 12 == 11

primes = is_prime.map((v, k) -> v and k).filter -> it
console.log primes


$, messagebar, mapMembersAPI, mapUserAPI, syncUserLocation, allUsers <-! define <[
  jquery messagebar map/members map/user data/sync data/allUsers domReady!
]>

# Text shown in the message bar when a search yield no results.
const NO_SEARCH_RESULTS_MESSAGE = '
  Those who you seek lie beyond our perception… but others await.
'

getUsername = -> $ it .find 'input[name=username]' .val!

# Setup user search.
$ \#search-form .on \submit !->
  username = getUsername this .toLowerCase!
  matches = allUsers.select -> (~it.username.toLowerCase!indexOf username)
  # If there are no results, at least clear the corresponding layer.
  mapMembersAPI.displaySearchResults matches
  if matches.length is 0
    messagebar.show NO_SEARCH_RESULTS_MESSAGE, \info

var g_marker
$ \#update-form
# Setup marker placement.
.one \submit !->
  $ '.leaflet-control-geosearch' .fadeIn!
  g_marker := mapUserAPI.placeUserMarker getUsername this
# Setup user location upload.
.one \submit !->
  <-! $(this).on \submit
  # Reset the upload button's color now, and set it to indicate success
  # once the upload is completed.
  $uploadButton =
    $(this).find 'button[type=submit]'
    .removeClass \btn-success
    .addClass \btn-default
  syncUserLocation (getUsername this), g_marker.getLatLng!, !->
    $uploadButton.toggleClass 'btn-default btn-success'

Clear search results layer on search form reset

$, messagebar, mapMembersAPI, mapUserAPI, syncUserLocation, allUsers <-! define <[
  jquery messagebar map/members map/user data/sync data/allUsers domReady!
]>

# Text shown in the message bar when a search yield no results.
const NO_SEARCH_RESULTS_MESSAGE = '
  Those who you seek lie beyond our perception… but others await.
'

getUsername = -> $ it .find 'input[name=username]' .val!

# Setup user search.
$ \#search-form
.on \submit !->
  username = getUsername this .toLowerCase!
  matches = allUsers.select -> (~it.username.toLowerCase!indexOf username)
  # If there are no results, at least clear the corresponding layer.
  mapMembersAPI.displaySearchResults matches
  if matches.length is 0
    messagebar.show NO_SEARCH_RESULTS_MESSAGE, \info
.on \reset !->
  mapMembersAPI.displaySearchResults []

var g_marker
$ \#update-form
# Setup marker placement.
.one \submit !->
  $ '.leaflet-control-geosearch' .fadeIn!
  g_marker := mapUserAPI.placeUserMarker getUsername this
# Setup user location upload.
.one \submit !->
  <-! $(this).on \submit
  # Reset the upload button's color now, and set it to indicate success
  # once the upload is completed.
  $uploadButton =
    $(this).find 'button[type=submit]'
    .removeClass \btn-success
    .addClass \btn-default
  syncUserLocation (getUsername this), g_marker.getLatLng!, !->
    $uploadButton.toggleClass 'btn-default btn-success'


define ->
	class Stencil
		/*
			Constructor takes a reference to a canvas with an SVG element in {svg} to draw atoms on.
			Requires a `canvas`.
		*/
		(@canvas)->
			@prepare @canvas

		/*
			Prep the canvas with any common tools needed.
			Generally, call the super method as the first action in the overloaded method then put
			gradients, filters etc in `defs`.
		 */
		prepare: (canvas = @canvas)->
			defs = @canvas.svg.select \defs

		/*
			Pass specific data for this particular element (eg position in the layer) in the first params,
			and an svg:g or svg:svg element in the last position as the layer to draw on.
		 */
		draw: (data, layer = @canvas.svg)->
			throw "Draw not implemented."

Update to new Stencil "best practices"

define ->
	Stencil = do
		/*
			Prep the canvas with any common tools needed.
			Generally, call the super method as the first action in the overloaded method then put
			gradients, filters etc in `defs`.
		 */
		prepare = (canvas = @canvas)->
			defs = @canvas.svg.select \defs

		/*
			Constructor takes a reference to a canvas with an SVG element in {svg} to draw atoms on.
			Requires a `canvas`.
		*/
		(@canvas, prepare = prepare)->
			@prepare @canvas

			/*
				Pass specific data for this particular element (eg position in the layer) in the first params,
				and an svg:g or svg:svg element in the last position as the layer to draw on.
			 */
			(data, layer = @canvas.svg)->
				throw "Draw not implemented."