Title here
Summary here
PureScript has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
-- Strings, which can be concatenated with <>
log $ "pure" <> "script"
-- Integers and floats
log $ "1+1 = " <> show (1 + 1)
log $ "7.0/3.0 = " <> show (7.0 / 3.0)
-- Booleans, with boolean operators as you'd expect
log $ show (true && false)
log $ show (true || false)
log $ show (not true)To run this program, save it as Values.purs and use the PureScript compiler and runtime:
$ spago run
purescript
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
falseIn this PureScript example:
Main.Prelude for basic operations, Effect for handling side effects, and Effect.Console for logging to the console.main function is defined as an Effect Unit, which is similar to IO () in Haskell.<> operator instead of +.show to convert values to strings for logging.log function is used instead of fmt.Println for console output.PureScript, being a strongly-typed functional language, has some differences from imperative languages:
<> for string concatenation instead of +.log return an Effect, which represents side effects.This example demonstrates basic value types and operations in PureScript, showing how it handles strings, numbers, and booleans in a functional programming context.