From: Camil Staps Date: Wed, 27 Jan 2016 18:04:27 +0000 (+0100) Subject: Added Maybe-related functions; restricted imports from .dcl X-Git-Tag: v0.3^2~1 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=45b44a6423c29de73de77b39e1d7c6e309962844;p=CleanReadLine.git Added Maybe-related functions; restricted imports from .dcl --- diff --git a/ReadLine.dcl b/ReadLine.dcl index 734ca20..7828e88 100644 --- a/ReadLine.dcl +++ b/ReadLine.dcl @@ -1,6 +1,6 @@ definition module ReadLine -import StdEnv +import StdClass :: Maybe a = Nothing | Just a :: HistoryItem = {line :: String, timestamp :: String} @@ -9,6 +9,11 @@ import StdEnv instance toString HistoryItem instance toString HistoryState +//Maybe functions +isNothing :: !(Maybe .x) -> Bool +isJust :: !(Maybe .x) -> Bool +fromJust :: !(Maybe .x) -> .x + //Non-library functions setReadLineName :: !String !*env -> *env diff --git a/ReadLine.icl b/ReadLine.icl index 790db28..4faf3ba 100644 --- a/ReadLine.icl +++ b/ReadLine.icl @@ -4,6 +4,18 @@ import StdEnv import code from "readLine.o" +//Maybe +isNothing :: !(Maybe .x) -> Bool +isNothing Nothing = True +isNothing _ = False + +isJust :: !(Maybe .x) -> Bool +isJust Nothing = False +isJust _ = True + +fromJust :: !(Maybe .x) -> .x +fromJust (Just x) = x + instance toString HistoryItem where toString {line,timestamp} = line +++ " (" +++ timestamp +++ ")" instance toString HistoryState where