Haskell "Dot Hack"

2 answers

I assume that it refers to the following line:

import Prelude hiding ((.))

which disables the normal operator (.)for functional composition. Instead, another operator with the same name is used, probably imported from the service module T.T. This operator behaves as in OOP languages:

pretty_output solution = solution.elems.map(show).in_group_of(9)
    .map(unwords).unlines

which (I think) usually looks like

pretty_output solution = (unlines . map unwords . in_group_of 9 . map show . elems) solution

This operator works the same as the operator |>in F #:

(|>) :: a -> (a -> b) -> b
x |> f = f x

which is used to pass values ​​through functions (and a more readable and improved functional style, imo):

pretty_output solution = solution |> elems |> map show |> in_group_of 9 |> map unwords |> unlines

(|>)also matches with flip ($).

: "" Haskell. Control.Category:

g x = x |> (f1 >>> f2 >>> f3)

, f >>> g = g . f.

+5

thing.method

thing

method thing

.

row i = i `div` 9
col i = i `mod` 9
row_list i positions = positions.select(on_i_row) where
  on_i_row pos = pos.row  == i.row
col_list i positions = positions.select(on_i_col) where
  on_i_col pos = pos.col == i.col

.

+4

All Articles