mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-15 21:23:57 +00:00
Pluralize PlatformTasks module
This commit is contained in:
parent
6db429ff17
commit
79cfcb072b
19 changed files with 69 additions and 69 deletions
|
|
@ -1,11 +1,11 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
# adapted from https://github.com/koka-lang/koka/blob/master/test/bench/haskell/cfold.hs
|
||||
main : Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -22,10 +22,10 @@ main =
|
|||
|> Num.toStr
|
||||
|> Str.concat " & "
|
||||
|> Str.concat (Num.toStr optimized)
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
Expr : [
|
||||
Add Expr Expr,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
# based on: https://github.com/koka-lang/koka/blob/master/test/bench/haskell/deriv.hs
|
||||
IO a : Task a []
|
||||
|
||||
main : Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -26,7 +26,7 @@ main =
|
|||
|> Task.map \_ -> {}
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
nestHelp : I64, (I64, Expr -> IO Expr), I64, Expr -> IO Expr
|
||||
nestHelp = \s, f, m, x ->
|
||||
|
|
@ -167,5 +167,5 @@ deriv = \i, f ->
|
|||
Num.toStr (i + 1)
|
||||
|> Str.concat " count: "
|
||||
|> Str.concat (Num.toStr (count fprime))
|
||||
PlatformTask.putLine! line
|
||||
PlatformTasks.putLine! line
|
||||
Task.ok fprime
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import Issue2279Help
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
main =
|
||||
text =
|
||||
|
|
@ -10,4 +10,4 @@ main =
|
|||
else
|
||||
Issue2279Help.asText 42
|
||||
|
||||
PlatformTask.putLine text
|
||||
PlatformTasks.putLine text
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
main : Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -15,10 +15,10 @@ main =
|
|||
Ok n ->
|
||||
queens n # original koka 13
|
||||
|> Num.toStr
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
ConsList a : [Nil, Cons a (ConsList a)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
hosted PlatformTask
|
||||
hosted PlatformTasks
|
||||
exposes [putLine, putInt, getInt]
|
||||
imports []
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
import Quicksort
|
||||
|
||||
main : Task.Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -24,10 +24,10 @@ main =
|
|||
|
||||
sort unsortedList
|
||||
|> Quicksort.show
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
sort : List I64 -> List I64
|
||||
sort = \list ->
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
Color : [Red, Black]
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ fold = \f, tree, b ->
|
|||
|
||||
main : Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -58,13 +58,13 @@ main =
|
|||
|
||||
val
|
||||
|> Num.toStr
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
Nil ->
|
||||
PlatformTask.putLine "fail"
|
||||
PlatformTasks.putLine "fail"
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
insert : Tree (Num k) v, Num k, v -> Tree (Num k) v
|
||||
insert = \t, k, v -> if isRed t then setBlack (ins t k v) else ins t k v
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
Color : [Red, Black]
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ ConsList a : [Nil, Cons a (ConsList a)]
|
|||
|
||||
main : Task {} []
|
||||
main =
|
||||
{ value, isError } = PlatformTask.getInt!
|
||||
{ value, isError } = PlatformTasks.getInt!
|
||||
inputResult =
|
||||
if isError then
|
||||
Err GetIntError
|
||||
|
|
@ -26,10 +26,10 @@ main =
|
|||
|
||||
val
|
||||
|> Num.toStr
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
Err GetIntError ->
|
||||
PlatformTask.putLine "Error: Failed to get Integer from stdin."
|
||||
PlatformTasks.putLine "Error: Failed to get Integer from stdin."
|
||||
|
||||
boom : Str -> a
|
||||
boom = \_ -> boom ""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
main : Task {} []
|
||||
main =
|
||||
|
|
@ -9,7 +9,7 @@ main =
|
|||
|
||||
tree
|
||||
|> show
|
||||
|> PlatformTask.putLine
|
||||
|> PlatformTasks.putLine
|
||||
|
||||
show : RedBlackTree I64 {} -> Str
|
||||
show = \tree -> showRBTree tree Num.toStr (\{} -> "{}")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
import AStar
|
||||
|
||||
main : Task {} []
|
||||
main =
|
||||
PlatformTask.putLine! (showBool test1)
|
||||
PlatformTasks.putLine! (showBool test1)
|
||||
|
||||
showBool : Bool -> Str
|
||||
showBool = \b ->
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
app [main] { pf: platform "platform/main.roc" }
|
||||
|
||||
import Base64
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
IO a : Task a []
|
||||
|
||||
main : IO {}
|
||||
main =
|
||||
when Base64.fromBytes (Str.toUtf8 "Hello World") is
|
||||
Err _ -> PlatformTask.putLine "sadness"
|
||||
Err _ -> PlatformTasks.putLine "sadness"
|
||||
Ok encoded ->
|
||||
PlatformTask.putLine! (Str.concat "encoded: " encoded)
|
||||
PlatformTasks.putLine! (Str.concat "encoded: " encoded)
|
||||
|
||||
when Base64.toStr encoded is
|
||||
Ok decoded -> PlatformTask.putLine (Str.concat "decoded: " decoded)
|
||||
Err _ -> PlatformTask.putLine "sadness"
|
||||
Ok decoded -> PlatformTasks.putLine (Str.concat "decoded: " decoded)
|
||||
Err _ -> PlatformTasks.putLine "sadness"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
hosted PlatformTask
|
||||
hosted PlatformTasks
|
||||
exposes [putLine, getLine]
|
||||
imports []
|
||||
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
app [main] { pf: platform "effects-platform/main.roc" }
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
main : Task {} []
|
||||
main =
|
||||
line = PlatformTask.getLine!
|
||||
PlatformTask.putLine! "You entered: $(line)"
|
||||
PlatformTask.putLine! "It is known"
|
||||
line = PlatformTasks.getLine!
|
||||
PlatformTasks.putLine! "You entered: $(line)"
|
||||
PlatformTasks.putLine! "It is known"
|
||||
|
||||
Task.ok {}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
module [line, withOpen, chunk, Handle]
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
Handle := U64
|
||||
|
||||
line : Handle -> Task Str *
|
||||
line = \@Handle handle -> PlatformTask.getFileLine handle
|
||||
line = \@Handle handle -> PlatformTasks.getFileLine handle
|
||||
|
||||
chunk : Handle -> Task (List U8) *
|
||||
chunk = \@Handle handle -> PlatformTask.getFileBytes handle
|
||||
chunk = \@Handle handle -> PlatformTasks.getFileBytes handle
|
||||
|
||||
open : Str -> Task Handle *
|
||||
open = \path ->
|
||||
PlatformTask.openFile path
|
||||
PlatformTasks.openFile path
|
||||
|> Task.map @Handle
|
||||
|
||||
close : Handle -> Task.Task {} *
|
||||
close = \@Handle handle -> PlatformTask.closeFile handle
|
||||
close = \@Handle handle -> PlatformTasks.closeFile handle
|
||||
|
||||
withOpen : Str, (Handle -> Task {} a) -> Task {} a
|
||||
withOpen = \path, callback ->
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
hosted PlatformTask
|
||||
hosted PlatformTasks
|
||||
exposes [openFile, closeFile, withFileOpen, getFileLine, getFileBytes, putLine, putRaw, getLine, getChar]
|
||||
imports []
|
||||
|
||||
|
|
@ -3,10 +3,10 @@ module [
|
|||
char,
|
||||
]
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
line : Task Str *
|
||||
line = PlatformTask.getLine
|
||||
line = PlatformTasks.getLine
|
||||
|
||||
char : Task U8 *
|
||||
char = PlatformTask.getChar
|
||||
char = PlatformTasks.getChar
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
module [line, raw]
|
||||
|
||||
import pf.PlatformTask
|
||||
import pf.PlatformTasks
|
||||
|
||||
line : Str -> Task {} *
|
||||
line = PlatformTask.putLine
|
||||
line = PlatformTasks.putLine
|
||||
|
||||
raw : Str -> Task {} *
|
||||
raw = PlatformTask.putRaw
|
||||
raw = PlatformTasks.putRaw
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module [
|
|||
dispatchEvent,
|
||||
]
|
||||
|
||||
import PlatformTask exposing [
|
||||
import PlatformTasks exposing [
|
||||
NodeId,
|
||||
HandlerId,
|
||||
TagName,
|
||||
|
|
@ -164,19 +164,19 @@ indexNodes = \{ nodes, siblingIds }, unrendered ->
|
|||
applyPatch : Patch -> Task {} *
|
||||
applyPatch = \patch ->
|
||||
when patch is
|
||||
CreateElement nodeId tagName -> PlatformTask.createElement nodeId tagName
|
||||
CreateTextNode nodeId content -> PlatformTask.createTextNode nodeId content
|
||||
UpdateTextNode nodeId content -> PlatformTask.updateTextNode nodeId content
|
||||
AppendChild parentId childId -> PlatformTask.appendChild parentId childId
|
||||
RemoveNode id -> PlatformTask.removeNode id
|
||||
ReplaceNode oldId newId -> PlatformTask.replaceNode oldId newId
|
||||
SetAttribute nodeId attrName value -> PlatformTask.setAttribute nodeId attrName value
|
||||
RemoveAttribute nodeId attrName -> PlatformTask.removeAttribute nodeId attrName
|
||||
SetProperty nodeId propName json -> PlatformTask.setProperty nodeId propName json
|
||||
RemoveProperty nodeId propName -> PlatformTask.removeProperty nodeId propName
|
||||
SetStyle nodeId key value -> PlatformTask.setStyle nodeId key value
|
||||
SetListener nodeId eventType accessorsJson handlerId -> PlatformTask.setListener nodeId eventType accessorsJson handlerId
|
||||
RemoveListener nodeId handlerId -> PlatformTask.removeListener nodeId handlerId
|
||||
CreateElement nodeId tagName -> PlatformTasks.createElement nodeId tagName
|
||||
CreateTextNode nodeId content -> PlatformTasks.createTextNode nodeId content
|
||||
UpdateTextNode nodeId content -> PlatformTasks.updateTextNode nodeId content
|
||||
AppendChild parentId childId -> PlatformTasks.appendChild parentId childId
|
||||
RemoveNode id -> PlatformTasks.removeNode id
|
||||
ReplaceNode oldId newId -> PlatformTasks.replaceNode oldId newId
|
||||
SetAttribute nodeId attrName value -> PlatformTasks.setAttribute nodeId attrName value
|
||||
RemoveAttribute nodeId attrName -> PlatformTasks.removeAttribute nodeId attrName
|
||||
SetProperty nodeId propName json -> PlatformTasks.setProperty nodeId propName json
|
||||
RemoveProperty nodeId propName -> PlatformTasks.removeProperty nodeId propName
|
||||
SetStyle nodeId key value -> PlatformTasks.setStyle nodeId key value
|
||||
SetListener nodeId eventType accessorsJson handlerId -> PlatformTasks.setListener nodeId eventType accessorsJson handlerId
|
||||
RemoveListener nodeId handlerId -> PlatformTasks.removeListener nodeId handlerId
|
||||
|
||||
applyPatches : List Patch -> Task {} *
|
||||
applyPatches = \patches ->
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
hosted PlatformTask
|
||||
hosted PlatformTasks
|
||||
exposes [
|
||||
NodeId,
|
||||
HandlerId,
|
||||
Loading…
Add table
Add a link
Reference in a new issue