on master help sign in
Merge pull request #335 from david-christiansen/providers-work
b915635Edwin Brady
src/Core/Execute.hs+11−1
@@ -274,6 +274,16 @@ execApp' env ctxt f@(EP _ (UN "mkForeign") _) args@(ty:fn:xs) | Just (FFun f arg
274 Just r -> return (mkEApp r (drop (length argTs) xs))
274 Just r -> return (mkEApp r (drop (length argTs) xs))
275 | otherwise = return (mkEApp f args)
275 | otherwise = return (mkEApp f args)
276
276
277+execApp' env ctxt c@(EP (DCon _ arity) n _) args =
278+ do args' <- mapM tryForce (take arity args)
279+ let restArgs = drop arity args
280+ execApp' env ctxt (mkEApp c args') restArgs
281+
282+execApp' env ctxt c@(EP (TCon _ arity) n _) args =
283+ do args' <- mapM tryForce (take arity args)
284+ let restArgs = drop arity args
285+ execApp' env ctxt (mkEApp c args') restArgs
286+
277execApp' env ctxt f@(EP _ n _) args =
287execApp' env ctxt f@(EP _ n _) args =
278 do let val = lookupDef n ctxt
288 do let val = lookupDef n ctxt
279 case val of
289 case val of
@@ -350,7 +360,7 @@ execApp' env ctxt f@(EP _ n _) args =
350 return (EConstant (Str line))
360 return (EConstant (Str line))
351 getOp (UN "prim__readString") [EHandle h] =
361 getOp (UN "prim__readString") [EHandle h] =
352 Just $ do contents <- execIO $ hGetLine h
362 Just $ do contents <- execIO $ hGetLine h
353− return (EConstant (Str contents))
363+ return (EConstant (Str (contents ++ "\n")))
354 getOp (UN "prim__shLInt") [EConstant (I i1), EConstant (I i2)] =
364 getOp (UN "prim__shLInt") [EConstant (I i1), EConstant (I i2)] =
355 primRes I (shiftL i1 i2)
365 primRes I (shiftL i1 i2)
356 getOp (UN "prim__shRInt") [EConstant (I i1), EConstant (I i2)] =
366 getOp (UN "prim__shRInt") [EConstant (I i1), EConstant (I i2)] =
test/test026/test026.idr+1−1
@@ -13,7 +13,7 @@ strToType _ = Nat
13-- If the file contains "Int", provide Int as a type, otherwise provide Nat
13-- If the file contains "Int", provide Int as a type, otherwise provide Nat
14fromFile : String -> IO (Provider Type)
14fromFile : String -> IO (Provider Type)
15fromFile fname = do str <- readFile fname
15fromFile fname = do str <- readFile fname
16− return (Provide (strToType str))
16+ return (Provide (strToType (trim str)))
17
17
18%provide (T1 : Type) with fromFile "theType"
18%provide (T1 : Type) with fromFile "theType"
19%provide (T2 : Type) with fromFile "theOtherType"
19%provide (T2 : Type) with fromFile "theOtherType"