Code background grey, use special code-block for GHCi

This commit is contained in:
Julian Ospald 2015-04-20 20:15:46 +02:00
parent e04217c4c0
commit 6438c6fb02
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
4 changed files with 35 additions and 18 deletions

View File

@ -1,9 +1,8 @@
GHCi: \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
\begin{haskellcode}
> 3 + 5 > 3 + 5
> (3 :: Integer) + (5 :: Int) > (3 :: Integer) + (5 :: Int)
> 6 * 5.0 > 6 * 5.0
> "Hello" ++ " world" > "Hello" ++ " world"
> "Haskell" > "C++" > "Haskell" > "C++"
> True && False > True && False
\end{haskellcode} \end{haskellcode*}

View File

@ -1,5 +1,5 @@
Let's check on a few very common list operations: Let's check on a few very common list operations:
\begin{haskellcode} \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
> [1, 2] ++ [4, 5] -- append two lists > [1, 2] ++ [4, 5] -- append two lists
> head [1, 2, 3] -- first element > head [1, 2, 3] -- first element
> tail [1, 2, 3] -- everything after the head > tail [1, 2, 3] -- everything after the head
@ -8,12 +8,12 @@ Let's check on a few very common list operations:
> drop 2 [1, 2, 3] -- drop the first two elements > drop 2 [1, 2, 3] -- drop the first two elements
> sum [1, 2, 3] > sum [1, 2, 3]
> elem 7 [1, 2, 3] -- is there a 7 in the list? > elem 7 [1, 2, 3] -- is there a 7 in the list?
\end{haskellcode} \end{haskellcode*}
\pause \pause
A String in haskell is just a list of Chars! A String in haskell is just a list of Chars!
\begin{haskellcode} \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
> ['a', 'b', 'c'] > ['a', 'b', 'c']
> 'a' : [] > 'a' : []
> head "abc" > head "abc"
> 'a' ++ 'c' > 'a' ++ 'c'
\end{haskellcode} \end{haskellcode*}

View File

@ -7,13 +7,13 @@ $S = \{2 \times x\ |\ x \in \mathbb{N},\ x \leq 10\}$
\\ \\
How does this look in haskell? How does this look in haskell?
\pause \pause
\begin{haskellcode} \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
> [ 2 * x | x <- [1..10]] > [ 2 * x | x <- [1..10]]
\end{haskellcode} \end{haskellcode*}
\pause \pause
Now let's say we want all numbers between 50 and 100 that have the remainder 0 when divided by 12: Now let's say we want all numbers between 50 and 100 that have the remainder 0 when divided by 12:
\pause \pause
\begin{haskellcode} \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
> [x | x <- [50..100], mod x 12 == 0] > [x | x <- [50..100], mod x 12 == 0]
\end{haskellcode} \end{haskellcode*}
\code{x <- [50..100]} is the binding, while \code{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates. \code{x <- [50..100]} is the binding, while \code{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates.

View File

@ -13,22 +13,40 @@
\usepackage[T1]{fontenc} \usepackage[T1]{fontenc}
\usepackage[Q=yes]{examplep} \usepackage[Q=yes]{examplep}
% color definition
\definecolor{solarized}{HTML}{002B36}
\definecolor{mygreen}{HTML}{009900}
\definecolor{mygrey}{rgb}{0.95,0.95,0.95}
% package configuration % package configuration
\DeclareGraphicsExtensions{.pdf,.png,.jpg} \DeclareGraphicsExtensions{.pdf,.png,.jpg}
\beamertemplatenavigationsymbolsempty \beamertemplatenavigationsymbolsempty
\setbeamertemplate{footline}[frame number] \setbeamertemplate{footline}[frame number]
% minted
%% fix the minted@colorbg environment
\makeatletter
\renewenvironment{minted@colorbg}[1]
{\def\minted@bgcol{#1}%
\noindent
\begin{lrbox}{\minted@bgbox}
\begin{minipage}{\linewidth-2\fboxsep}}
{\end{minipage}%
\end{lrbox}%
\setlength{\topsep}{\smallskipamount}% set the vertical space
\trivlist\item\relax % ensure going to a new line
\colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}%
\endtrivlist % close the trivlist
}
\makeatother
\usemintedstyle{friendly} \usemintedstyle{friendly}
\newminted{haskell}{frame=single,numbers=left} \newminted{haskell}{bgcolor=mygrey,frame=single,numbers=left}
\newminted{cpp}{frame=single,numbers=left} \newminted{cpp}{bgcolor=mygrey,frame=single,numbers=left}
\newminted{c}{frame=single,numbers=left} \newminted{c}{bgcolor=mygrey,frame=single,numbers=left}
\renewcommand{\theFancyVerbLine}{\ttfamily \renewcommand{\theFancyVerbLine}{\ttfamily
\textcolor[rgb]{0.0,0.0,0.0}{\footnotesize \textcolor[rgb]{0.0,0.0,0.0}{\footnotesize
\oldstylenums{\arabic{FancyVerbLine}}}} \oldstylenums{\arabic{FancyVerbLine}}}}
% color definition
\definecolor{solarized}{HTML}{002B36}
\definecolor{mygreen}{rgb}{0,0.6,0}
% macros and environments % macros and environments
\newcommand{\code}[1]{\texttt{#1}} \newcommand{\code}[1]{\texttt{#1}}
\newcommand{\slidep}{\onslide<+->} \newcommand{\slidep}{\onslide<+->}