[PureScript] Introduce to PureScript Specify Function Arguments
to Function arguments specify
2023-09-14 09:00:49 时间
JavaScript does its error-checking at runtime, but PureScript has a compiler, which makes sure that your program has no errors before it converts it all into JavaScript.
PureScript's compiler uses a type system to catch errors so that you aren’t accidentally mismatching your types. We will learn the very basics of type declarations, how they work in a statically typed language like PureScript, and see simple examples of them in action.
Join in by going to PureScripts online editor
Define a variable type:
myTypes :: Int myTypes = 1
Define a function:
add :: Int -> Int -> Int // Take a Int, another Int, return value is also Int add a b = a + b
We can also define the function like that:
add = \a -> \b -> a + b
We can also define curry function:
-- inc (a -> (add 1 a)) inc :: Int -> Int inc = add 1 main = render =<< withConsole do log $ show $ inc 5
Full code:
module Main where import Prelude import Control.Monad.Eff.Console (log) import TryPureScript myTypes :: Int myTypes = 1 -- add (a -> (b -> (a + b))) add :: Int -> Int -> Int add a b = a + b addMe = \a -> \b -> a + b -- inc (a -> (add 1 a)) inc :: Int -> Int inc = add 1 main = render =<< withConsole do log $ show $ inc 5 // 6
相关文章
- boost::bind 不能处理函数重载 (error: no matching function for call to 'bind')
- 报错:warning: large integer implicitly truncated to unsigned type [-Woverflow]
- Python librosa.frames_to_time()和librosa.samples_like()的用法
- ORA-26747: The one-to-many transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-26748: The one-to-one transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-26754: cannot specify both one-to-one transformation function string and one-to-many transformation function string ORACLE 报错 故障修复 远程处理
- ORA-27064: cannot perform async I/O to file ORACLE 报错 故障修复 远程处理
- ORA-27150: attempt to notify process of pending oradebug call failed ORACLE 报错 故障修复 远程处理
- ORA-28004: invalid argument for function specified in PASSWORD_VERIFY_FUNCTION string ORACLE 报错 故障修复 远程处理
- ORA-29659: SQLJ Object Type validation failed to get default connection ORACLE 报错 故障修复 远程处理
- ORA-30150: Invalid argument passed to OCIFile function ORACLE 报错 故障修复 远程处理
- ORA-30202: NULL pointer to OCIMsgh was passed to OCIMsg function ORACLE 报错 故障修复 远程处理
- ORA-64126: XMLIndex Table Function: failure at the start of the function ORACLE 报错 故障修复 远程处理
- ORA-64127: XMLIndex Table Function: failure at the beginning of the function ORACLE 报错 故障修复 远程处理
- ORA-01342: LogMiner can not resume session due to inability of staging checkpointed data ORACLE 报错 故障修复 远程处理
- ORA-06443: ssvpstev: Incorrect parameter passed to function call ORACLE 报错 故障修复 远程处理
- ORA-13471: unable to determine the owner of string ORACLE 报错 故障修复 远程处理
- ORA-16444: ALTER SYSTEM FLUSH REDO TO STANDBY failed due to a corrupted control file or online log file. ORACLE 报错 故障修复 远程处理
- ORA-19227: XPTY0007 – fn:data function is applied to a node (type (string)) whose type annotation denotes a complex type with non-mixed complex content. ORACLE 报错 故障修复 远程处理
- RFC_GET_FUNCTION_INTERFACE_P获取函数(function module)参数详解编程语言