-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypes.idr
More file actions
64 lines (53 loc) · 1.98 KB
/
Copy pathTypes.idr
File metadata and controls
64 lines (53 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
||| VALENCE-SHELL (vsh) — ABI Type Definitions
|||
||| This module defines the Application Binary Interface for the Valence Shell.
||| It provides the formal specifications for shell transmutations and
||| command execution in verified environments.
module VALENCE_SHELL.ABI.Types
import Data.Bits
import Data.So
import Data.Vect
%default total
--------------------------------------------------------------------------------
-- Platform Context
--------------------------------------------------------------------------------
||| Supported targets for the Valence Shell kernel.
public export
data Platform = Linux | Windows | MacOS | BSD | WASM
||| Resolves the execution environment at compile time.
public export
thisPlatform : Platform
thisPlatform =
%runElab do
pure Linux
--------------------------------------------------------------------------------
-- Shell Result Codes
--------------------------------------------------------------------------------
||| Formal outcome of a shell operation.
public export
data Result : Type where
||| Command Succeeded (Exit 0)
Ok : Result
||| Command Failed (Non-zero exit)
Error : Result
||| Syntax Error: Malformed shell construct
InvalidParam : Result
||| System Error: Out of memory
OutOfMemory : Result
||| Safety Error: Unexpected null pointer
NullPointer : Result
--------------------------------------------------------------------------------
-- Opaque Shell Handles
--------------------------------------------------------------------------------
||| Opaque handle to a Valence Shell session.
||| INVARIANT: The internal pointer is guaranteed to be non-null.
public export
data Handle : Type where
MkHandle : (ptr : Bits64) -> {auto 0 nonNull : So (ptr /= 0)} -> Handle
||| Safe constructor for shell handles.
public export
createHandle : Bits64 -> Maybe Handle
createHandle 0 = Nothing
createHandle ptr = Just (MkHandle ptr)