You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
Let's introduce some helper types in order to avoid such a boilerplate
// FunctionN, where N = function aritytypeFunction1<A,B>=(_: A)=>B;typeFunction2<A,B,C>=(_: A)=>(_: B)=>C;typeFunction3<A,B,C,D>=(_: A)=>(_: B)=>(_: C)=>D;
instanceshowBoolean :: ShowBooleanwhere
show true = "true"
show false = "false"instanceshowMaybe :: (Showa) =>Show (Maybea) where
show Nothing = "Nothing"
show (Just x) = "Just(" <> show x <> ")"
Note. The term "FlowScript" here means JavaScript + Flow type annotations (+ PureScript idioms).
Functions
A basic example
PureScript
In FlowScript all functions must be curried
Let's introduce some helper types in order to avoid such a boilerplate
Now
add
is more readable:A function with universally quantified type
PureScript
In FlowScript, as a convention, every type parameter is uppercase
let..in
PureScript
in FlowScript
let
s are translated toconst
sData structures
type
PureScript
It's the same in FlowScript
data
FlowScript
Again, let's introduce some helpers
or even better
Now building some
Maybe
s is more handy:Another example.
PureScript
FlowScript
newtype
No equivalent :(
Recursive data structures
PureScript
FlowScript
Type classes
PureScript
FlowScript
Instances
PureScript
FlowScript
note how
showMaybe
takes an additionaldictShow
argument because of the(Show a) =>
contraint.Using
show
PureScript
FlowScript (a bit verbose...)
The text was updated successfully, but these errors were encountered: