Skip to content

Instantly share code, notes, and snippets.

View bartosz-witkowski's full-sized avatar

Bartosz Witkowski bartosz-witkowski

View GitHub Profile
@bartosz-witkowski
bartosz-witkowski / mercury-strange.m
Created December 10, 2013 21:49
Mercury strange compilation error.
:- module scheme.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string.
@bartosz-witkowski
bartosz-witkowski / zipper.m
Last active January 1, 2016 13:49
Zipper implementation in mercury.
%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
%---------------------------------------------------------------------------%
%
% File: zipper.m.
% Authors: Bartosz Witkowski
%
% This module defines a list zipper type which is a `one-hole-context' of
% the list data structure (vide ``The Derivative of a Regular Type is its
% Type of One-Hole Contexts'' by Conor McBride).
@bartosz-witkowski
bartosz-witkowski / mecury_store.m
Last active July 12, 2020 03:09
Example of using the mercury store.
:- module store_example.
:- interface.
:- import_module store, io.
:- pred main(io::di, io::uo) is det.
:- some [S] pred new_counter(int_var(S)::out, S::uo) is det => store(S).
:- implementation.
@bartosz-witkowski
bartosz-witkowski / stack_var_out_of_range.m
Last active January 3, 2016 20:19
mercury: stack var out of range error.
:- module stack_var_out_of_range.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module store, int.
@bartosz-witkowski
bartosz-witkowski / exist.m
Created January 22, 2014 00:54
Existentially typed data type in mercury
:- module scheme.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string, int, list, store, map.
:- module mtest.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module integer, string, list.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The picture language
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Exercise 2.44
;; -------------
:- module subtyping.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string, int, list.
:- module subtyping.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module string, int, list.
val _10 = Stream.from(1).take(10)
val data = Stream.continually(_10).take(10).flatten.toArray
// Exiting paste mode, now interpreting.
_10: scala.collection.immutable.Stream[Int] = Stream(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
data: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> :paste
// Entering paste mode (ctrl-D to finish)