Commit 3f6b22b5 authored by Peter Achten's avatar Peter Achten
Browse files

PA: In StdPSt: PSt is now an instance of the FileSystem class.

In StdMaybe redundant appMaybe (mapMaybe) removed.
parent 64f861fb
......@@ -18,10 +18,6 @@ isJust :: !(Maybe .x) -> Bool // case @1 of (Just _) -> True; _ -> False
isNothing :: !(Maybe .x) -> Bool // not o isJust
fromJust :: !(Maybe .x) -> .x // \(Just x) -> x
appMaybe :: .(IdFun .x) !(Maybe .x) -> Maybe .x
// appMaybe f (Just x) = Just (f x)
// appMaybe f Nothing = Nothing
accMaybe :: .(St .x .a) !(Maybe .x) -> (!Maybe .a,!Maybe .x)
// accMaybe f (Just x) = (Just (fst (f x)),Just (snd (f x)))
// accMaybe f Nothing = (Nothing,Nothing)
......
......@@ -25,10 +25,6 @@ isNothing _ = False
fromJust :: !(Maybe .x) -> .x
fromJust (Just x) = x
appMaybe :: .(IdFun .x) !(Maybe .x) -> Maybe .x
appMaybe f (Just x) = Just (f x)
appMaybe _ nothing = nothing
accMaybe :: .(St .x .a) !(Maybe .x) -> (!Maybe .a,!Maybe .x)
accMaybe f (Just x)
# (a,x) = f x
......
......@@ -18,6 +18,7 @@ from channelenv import ChannelEnv // MW11++
/* PSt is an environment instance of the following classes:
- FileSystem (see StdFile)
- FileEnv (see StdFile)
- FileSelectEnv (see StdFileSelect)
- TimeEnv (see StdTime)
......@@ -27,6 +28,7 @@ from channelenv import ChannelEnv // MW11++
IOSt is also an environment instance of the classes FileEnv, TimeEnv & ChannelEnv
*/
instance FileSystem (PSt .l .p)
instance FileEnv (PSt .l .p), (IOSt .l .p) // MW11 added IOSt
instance FileSelectEnv (PSt .l .p)
instance TimeEnv (PSt .l .p), (IOSt .l .p) // MW11 added IOSt
......
......@@ -18,6 +18,37 @@ from ostoolbox import OSNewToolbox, WorldGetToolbox, WorldSetToolbox
import StdReceiver, receiverid, receiverhandle, receiverdevice, channelenv // MW11++
/* PSt is an environment instance of the class FileEnv (see StdFile).
*/
instance FileSystem (PSt .l .p) where
fopen :: !{#Char} !Int !(PSt .l .p) -> (!Bool,!*File,!PSt .l .p)
fopen fName fMode pState
# ((ok,file),pState) = accFiles (fopen` fName fMode) pState
= (ok,file,pState)
where
fopen` :: !{#Char} !Int !*Files -> (!(!Bool,!*File),!*Files)
fopen` fName fMode files
# (ok,file,files) = fopen fName fMode files
= ((ok,file),files)
fclose :: !*File !(PSt .l .p) -> (!Bool,!PSt .l .p)
fclose file pState
= accFiles (fclose file) pState
stdio :: !(PSt .l .p) -> (!*File,!PSt .l .p)
stdio pState
= accFiles stdio pState
sfopen :: !{#Char} !Int !(PSt .l .p) -> (!Bool,!File,!PSt .l .p)
sfopen fName fMode pState
# ((ok,sfile),pState) = accFiles (sfopen` fName fMode) pState
= (ok,sfile,pState)
where
sfopen` :: !{#Char} !Int !*Files -> (!(!Bool,!File),!*Files)
sfopen` fName fMode files
# (ok,file,files) = sfopen fName fMode files
= ((ok,file),files)
/* PSt is an environment instance of the class FileEnv (see StdFile).
*/
instance FileEnv (PSt .l .p) where
......
......@@ -1611,11 +1611,11 @@ where
setwindowscrollfunction :: !Direction ScrollFunction !(WindowStateHandle .pst) -> WindowStateHandle .pst
setwindowscrollfunction direction scrollFun wsH=:{wshHandle=Just wlsH=:{wlsHandle=wH}}
| direction==Horizontal && isJust hScroll
# info = {windowInfo & windowHScroll=appMaybe (setScrollFun scrollFun) hScroll}
# info = {windowInfo & windowHScroll=mapMaybe (setScrollFun scrollFun) hScroll}
# wH = {wH & whWindowInfo=WindowInfo info}
= {wsH & wshHandle=Just {wlsH & wlsHandle=wH}}
| direction==Vertical && isJust vScroll
# info = {windowInfo & windowVScroll=appMaybe (setScrollFun scrollFun) vScroll}
# info = {windowInfo & windowVScroll=mapMaybe (setScrollFun scrollFun) vScroll}
# wH = {wH & whWindowInfo=WindowInfo info}
= {wsH & wshHandle=Just {wlsH & wlsHandle=wH}}
| otherwise
......
......@@ -1253,10 +1253,10 @@ where
# (found,itemHs,s) = setWElement (setCompoundScrollFun direction scrollFun) id itemH.wItems` s
= (found,{itemH & wItems`=itemHs},s)
| direction==Horizontal && isJust hScroll
# info = {info & compoundHScroll=appMaybe (setScrollFun scrollFun) hScroll}
# info = {info & compoundHScroll=mapMaybe (setScrollFun scrollFun) hScroll}
= (True,{itemH & wItemInfo`=CompoundInfo` info},s)
| direction==Vertical && isJust vScroll
# info = {info & compoundVScroll=appMaybe (setScrollFun scrollFun) vScroll}
# info = {info & compoundVScroll=mapMaybe (setScrollFun scrollFun) vScroll}
= (True,{itemH & wItemInfo`=CompoundInfo` info},s)
| otherwise
= (True,itemH,s)
......
Supports Markdown
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