Commit 394cee56 authored by bbr's avatar bbr
Browse files

external functions lifted to current state of the art

parent 6bcddb86
......@@ -19,8 +19,8 @@ instance Read IOHandle where
readsPrec = error "reading Handle"
instance Generate IOHandle where
genFree _ = error "free variable of type IO-Handle"
genPattern _ = error "narrowing type IO.Handle"
genFree = error "free variable of type IO-Handle"
maxArity _ = error "free variable of type IO-Handle"
......@@ -14,6 +14,6 @@ instance Read (IORef a) where
readsPrec = error "reading IOREF"
instance Generate (IORef a) where
genFree _ = error "free variable of type IOExts.IORef"
genPattern _ = error "free variable of type IOExts.IORef"
genFree = error "free variable of type IOExts.IORef"
maxArity _ = error "free variable of type IOExts.IORef"
......@@ -10,7 +10,7 @@ type C_Socket = Prim Socket
instance Read Socket where
instance Generate Socket where
genFree = error "no random sockets"
genPattern = error "no narrowing on sockets"
genFree = error "no random sockets"
maxArity = error "no narrowing on sockets"
......@@ -9,8 +9,8 @@ import Data.IORef
prim_isVar :: Curry a => a -> Result C_Bool
prim_isVar x _ = case consKind x of
Free -> either (const C_True) (const C_False) (binding x)
Val -> C_False
Branching -> toCurry (isGenerator (orRef x))
_ -> C_False
prim_unsafePerformIO :: Curry a => C_IO a -> Result a
prim_unsafePerformIO (C_IO action) st = unsafe (unsafePerformIO (action st)) st
......@@ -20,8 +20,6 @@ unsafe :: Curry a => IOVal a -> Result a
unsafe (IOVal v) _ = v
unsafe (IOValFail e) _ = Curry.failed e
unsafe (IOValOr r bs) st = mapOr (\ x -> unsafe (unsafePerformIO x)) r bs st
unsafe (IOValSusp _ _) _ = error $ "ExternalFunctionsUnsafe.unsafe susp"
unsafe (IOValFreeVar _) _ = error $ "ExternalFunctionsUnsafe.unsafe free"
{-
-- the main point about unsafe: the value of suspensions has to be stored.
unsafe (IOValSusp _ susp) = let sRef = nextSuspRef () in
......@@ -66,8 +64,12 @@ saveSuspValue sRef cont susp store =
prim_identicalVar :: Curry a => a -> a -> Result C_Bool
prim_identicalVar x y _ = case (consKind x,consKind y) of
(Free,Free) -> toCurry (freeVarRef x Prelude.== freeVarRef y)
_ -> C_False
(Branching,Branching) -> let rx = orRef x
ry = orRef y in
if isGenerator rx && isGenerator ry
then toCurry (deref rx Prelude.== deref ry)
else C_False
_ -> C_False
prim_showAnyTerm t _ = toCurry (show t)
......@@ -133,4 +135,4 @@ nrOfChoices :: Result (C_IO C_Int)
nrOfChoices st =
C_IO (\ st' -> Prelude.return (IOVal (toCurry (max (size' st) (size' st')))))
where
size' = maybe 0 storeSize
size' = storeSize
......@@ -595,16 +595,17 @@ strEqSuccess = C_True
-----------------------------------------------------------------
instance BaseCurry b => Generate (a -> Result b) where
genFree i = mkBranches (generator i)
--maxArity = (undefined,2)
genFree i = mkBranches (generator i)
maxArity _ = 1
mkBranches :: BaseCurry b => b -> [a -> Result b]
mkBranches x = case consKind x of
Val -> [const (const x)]
Val -> [const (const x)]
Branching -> map (const . const) (branches x)
instance Generate Float where
genFree _ = error "free variable of type Float"
genFree = error "free variable of type Float"
maxArity _ = error "free variable of type Float"
-----------------------------------------------------------------
-- external Curry instances
......
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