haskelldb

How do I create an operator in Haskell?

懵懂的女人 提交于 2019-12-20 10:23:21
问题 Making a ternary logic table, and I would like to make my own function for an operator that I'll call <=> . So, for example, I want to do this, but that isn't right. what's the correct way to do this? data Ternary = T | F | M deriving (Eq, Show, Ord) <=> :: Ternary -> Ternary -> Ternary <=> T F = F <=> T T = T <=> T M = M <=> F F = T <=> F T = F <=> F M = M <=> M F = M <=> M T = M <=> M M = T 回答1: Just add parentheses around your operator: (<=>) :: Ternary -> Ternary -> Ternary (<=>) T F = F

Basic example of using HaskellDB to unmap records of a table

旧城冷巷雨未停 提交于 2019-12-05 14:52:47
问题 Suppose that I have the following (PostgreSQL) table definition: CREATE TABLE books ( id serial NOT NULL, title character varying NOT NULL, PRIMARY KEY (id) ); And the following record definition: data Book = { id :: Int , title :: String } What is a basic example of an "unmap" function to query all books in the database, allBooks :: Database -> IO [Book] ? 回答1: It turns out that I was going about this the wrong way. After stumbling upon Mats Rauhala's exceedingly helpful blog post titled

Basic example of using HaskellDB to unmap records of a table

♀尐吖头ヾ 提交于 2019-12-04 02:16:26
Suppose that I have the following (PostgreSQL) table definition: CREATE TABLE books ( id serial NOT NULL, title character varying NOT NULL, PRIMARY KEY (id) ); And the following record definition: data Book = { id :: Int , title :: String } What is a basic example of an "unmap" function to query all books in the database, allBooks :: Database -> IO [Book] ? It turns out that I was going about this the wrong way. After stumbling upon Mats Rauhala 's exceedingly helpful blog post titled Example on using HaskellDB , I was able to write a test project to read the records of the books table. I

How do I create an operator in Haskell?

梦想的初衷 提交于 2019-12-02 22:03:59
Making a ternary logic table, and I would like to make my own function for an operator that I'll call <=> . So, for example, I want to do this, but that isn't right. what's the correct way to do this? data Ternary = T | F | M deriving (Eq, Show, Ord) <=> :: Ternary -> Ternary -> Ternary <=> T F = F <=> T T = T <=> T M = M <=> F F = T <=> F T = F <=> F M = M <=> M F = M <=> M T = M <=> M M = T Just add parentheses around your operator: (<=>) :: Ternary -> Ternary -> Ternary (<=>) T F = F (<=>) T T = T (<=>) T M = M (<=>) F F = T (<=>) F T = F (<=>) F M = M (<=>) M F = M (<=>) M T = M (<=>) M M