Commit e1512e64 authored by Martin Wierich's avatar Martin Wierich

removing definitions that are now part of StdLib

parent 96fe127e
definition module StdMaybe
// ********************************************************************************
// Clean Standard Object I/O library, version 1.2.1
//
// StdMaybe defines the Maybe type.
// ********************************************************************************
from StdFunc import St
from StdOverloaded import ==
from StdIOBasic import IdFun
:: Maybe x
= Just x
| Nothing
isJust :: !(Maybe .x) -> Bool // case @1 of (Just _) -> True; _ -> False
isNothing :: !(Maybe .x) -> Bool // not o isJust
fromJust :: !(Maybe .x) -> .x // \(Just x) -> x
// for possibly unique elements:
u_isJust :: !u:(Maybe v:x) -> (!Bool, !u:(Maybe v:x)), [u<=v]
u_isNothing :: !u:(Maybe v:x) -> (!Bool, !u:(Maybe v:x)), [u<=v]
accMaybe :: .(St u:x .a) !v:(Maybe u:x) -> (!Maybe .a,!v:(Maybe u:x)), [v<=u]
// accMaybe f (Just x) = (Just (fst (f x)),Just (snd (f x)))
// accMaybe f Nothing = (Nothing,Nothing)
mapMaybe :: .(.x -> .y) !(Maybe .x) -> Maybe .y
// mapMaybe f (Just x) = Just (f x)
// mapMaybe f Nothing = Nothing
instance == (Maybe x) | == x
// Nothing==Nothing
// Just a ==Just b <= a==b
implementation module StdMaybe
// ********************************************************************************
// Clean Standard Object I/O library, version 1.2.1
//
// StdMaybe defines the Maybe type.
// ********************************************************************************
from StdFunc import St
from StdOverloaded import ==
from StdIOBasic import IdFun
:: Maybe x
= Just x
| Nothing
isJust :: !(Maybe .x) -> Bool
isJust Nothing = False
isJust _ = True
isNothing :: !(Maybe .x) -> Bool
isNothing Nothing = True
isNothing _ = False
u_isJust :: !u:(Maybe v:x) -> (!Bool, !u:(Maybe v:x)), [u<=v]
u_isJust nothing=:Nothing
= (False, nothing)
u_isJust just
= (True, just)
u_isNothing :: !u:(Maybe v:x) -> (!Bool, !u:(Maybe v:x)), [u<=v]
u_isNothing nothing=:Nothing
= (True, nothing)
u_isNothing just
= (False,just)
fromJust :: !(Maybe .x) -> .x
fromJust (Just x) = x
accMaybe :: .(St u:x .a) !v:(Maybe u:x) -> (!Maybe .a,!v:(Maybe u:x)), [v<=u]
accMaybe f (Just x)
# (a,x) = f x
= (Just a,Just x)
accMaybe _ nothing
= (Nothing,nothing)
mapMaybe :: .(.x -> .y) !(Maybe .x) -> Maybe .y
mapMaybe f (Just x) = Just (f x)
mapMaybe _ nothing = Nothing
instance == (Maybe x) | == x where
(==) Nothing maybe = case maybe of
Nothing -> True
just -> False
(==) (Just a) maybe = case maybe of
Just b -> a==b
nothing -> False
......@@ -9,18 +9,7 @@ definition module StdTime
from StdOverloaded import <
from ostick import Tick
:: Time
= { hours :: !Int // hours (0-23)
, minutes :: !Int // minutes (0-59)
, seconds :: !Int // seconds (0-59)
}
:: Date
= { year :: !Int // year
, month :: !Int // month (1-12)
, day :: !Int // day (1-31)
, dayNr :: !Int // day of week (1-7, Sunday=1, Saturday=7)
}
from StdLibMisc import Time, Date
wait :: !Int .x -> .x
......
......@@ -6,18 +6,7 @@ implementation module StdTime
import StdBool, StdClass, StdFunc, StdInt, StdReal
import ostime, ossystem, /*MW11++*/ ostick
:: Time
= { hours :: !Int // hours (0-23)
, minutes :: !Int // minutes (0-59)
, seconds :: !Int // seconds (0-59)
}
:: Date
= { year :: !Int // year
, month :: !Int // month (1-12)
, day :: !Int // day (1-31)
, dayNr :: !Int // day of week (1-7, Sunday=1, Saturday=7)
}
from StdLibMisc import Time, Date
// Suspend evaluation of the second argument modally for a number of ticks (see StdSystem).
......
......@@ -247,6 +247,3 @@ where
IsCustomControl -> (osSetCustomControlShow, osDestroyCustomControl)
_ -> windowdisposeFatalError "disposeWItemHandle" ("unmatched ControlKind: "+++toString wItemKind)
maybeToList :: !(Maybe .x) -> [.x]
maybeToList (Just x) = [x]
maybeToList _ = []
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment