This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f19797a
commit 766745e
Showing
4 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module Lunarbox.Data.Dataflow.Native.Function (pipe, identity', const') where | ||
|
||
import Lunarbox.Data.Dataflow.Expression (NativeExpression(..)) | ||
import Lunarbox.Data.Dataflow.Native.NativeConfig (NativeConfig(..)) | ||
import Lunarbox.Data.Dataflow.Runtime (RuntimeValue(..), binaryFunction) | ||
import Lunarbox.Data.Dataflow.Scheme (Scheme(..)) | ||
import Lunarbox.Data.Dataflow.Type (TVarName(..), Type(..)) | ||
import Lunarbox.Data.Editor.FunctionData (internal) | ||
import Lunarbox.Data.Editor.FunctionName (FunctionName(..)) | ||
import Prelude (const, identity, ($)) | ||
|
||
typePipe :: Scheme | ||
typePipe = | ||
Forall [ input, output ] $ TArrow (TVarariable input) | ||
$ TArrow | ||
(TArrow (TVarariable input) (TVarariable output)) | ||
(TVarariable output) | ||
where | ||
input = TVarName "i" | ||
|
||
output = TVarName "o" | ||
|
||
evalPipe :: RuntimeValue -> RuntimeValue -> RuntimeValue | ||
evalPipe input (Function function) = function input | ||
|
||
evalPipe _ _ = Null | ||
|
||
pipe :: NativeConfig | ||
pipe = | ||
NativeConfig | ||
{ name: FunctionName "pipe" | ||
, expression: (NativeExpression typePipe $ binaryFunction evalPipe) | ||
, functionData: | ||
internal | ||
[ { name: "input" } | ||
, { name: "function" } | ||
] | ||
} | ||
|
||
typeIdentity :: Scheme | ||
typeIdentity = Forall [ input ] $ TArrow (TVarariable input) (TVarariable input) | ||
where | ||
input = TVarName "i" | ||
|
||
identity' :: NativeConfig | ||
identity' = | ||
NativeConfig | ||
{ name: FunctionName "identity" | ||
, expression: (NativeExpression typeIdentity $ Function identity) | ||
, functionData: | ||
internal | ||
[ { name: "input" } | ||
] | ||
} | ||
|
||
typeConst :: Scheme | ||
typeConst = Forall [ input, ignore ] $ TArrow (TVarariable input) $ TArrow (TVarariable ignore) (TVarariable input) | ||
where | ||
input = TVarName "input" | ||
|
||
ignore = TVarName "ignore" | ||
|
||
const' :: NativeConfig | ||
const' = | ||
NativeConfig | ||
{ name: FunctionName "pipe" | ||
, expression: (NativeExpression typeConst $ binaryFunction const) | ||
, functionData: | ||
internal | ||
[ { name: "constant value" } | ||
, { name: "ignored value" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters