Skip to main content Svelte Highlight v7.21.1

PureScript language preview

1. Module and a typed function

module header, a type signature, and a case expression
horizon-dark
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"
atom-one-dark
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"
github-dark
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"
dracula
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"
nord
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"
github
module Main where

double :: Int -> Int
double n = n + n

main :: Effect Unit
main = do
  let greeting = "Hello, " <> "world"
  case double 21 of
    42 -> log greeting
    _  -> log "nope"

2. Records and type classes

a record type, a type class, and an instance
horizon-dark
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"
atom-one-dark
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"
github-dark
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"
dracula
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"
nord
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"
github
type Point = { x :: Number, y :: Number }

class Describable a where
  describe :: a -> String

instance describablePoint :: Describable Point where
  describe p = "(" <> show p.x <> ", " <> show p.y <> ")"

3. Nested comments

a doc comment wrapping an example that has its own comment
horizon-dark
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n
atom-one-dark
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n
github-dark
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n
dracula
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n
nord
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n
github
{- computes the double of a number
   {- example: double 21 == 42 -}
-}
double :: Int -> Int
double n = n + n