瀏覽代碼

Reorder for improved clarity

stripped-german
Julian Ospald 9 年之前
父節點
當前提交
81170661bc
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 220CD1C5BDEED020
共有 1 個檔案被更改,包括 9 行新增10 行删除
  1. +9
    -10
      VL1.tex

+ 9
- 10
VL1.tex 查看文件

@@ -501,16 +501,6 @@ data MaybeInt = NoError Int
| Error String
\end{lstlisting}
\pause
And now we can do sanity checks:
\pause
\setHaskellCodeStyle
\begin{lstlisting}
calcSomething :: Int -> MaybeInt
calcSomething x
| x < 100 = NoError (x * 5)
| otherwise = Error "Int out of range!"
\end{lstlisting}
\pause
So constructors are just \emph{functions}! And they can have arguments, just like functions. Let's check their types:
\setHaskellCodeStyle
\begin{lstlisting}
@@ -519,6 +509,15 @@ NoError :: Int -> MaybeInt
> :t Error
Error :: String -> MaybeInt
\end{lstlisting}
\pause
And now we can do sanity checks:
\setHaskellCodeStyle
\begin{lstlisting}
calcSomething :: Int -> MaybeInt
calcSomething x
| x < 100 = NoError (x * 5)
| otherwise = Error "Int out of range!"
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]


Loading…
取消
儲存