naoto-ogawa / haskell-must-read

must-read articles, papers, QAs and so on.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

haskell-must-read

must-read articles, papers, QAs and so on.

haskell project structure

String

> S8.pack "abc" :: Data.ByteString.Char8.ByteString
"abc"
> S8.pack "abc" :: Data.ByteString.ByteString
"abc"
  • Type Conversion
        -->  T.pack  -->        --> encodeUtf8 -->        
String                    Text                      ByteString
        <-- T.unpack <--        <-- decodeUtf8 <-- 

        -->  C.pack  --> *warning* truncated occured, so .one char -> one byte. 
String                    ByteString
        <-- C.unpack <--
bytestring Data.ByteString       pack :: [Word8] -> ByteString
bytestring Data.ByteString.Lazy  pack :: [Word8] -> ByteString
bytestring Data.ByteString.Char8 pack :: String  -> ByteString
text       Data.Text             pack :: String  -> Text
text       Data.Text.Lazy        pack :: String  -> Text

for all

Point Free Style

Function Application vs Function Composition

Function application has higher precedence than any infix operator ** Examples

a b . c d
--->
OK --> (a b) . (c d)
NG -->  a (b . c) d
> gcd 5 (5^2)
5
> gcd 5 5^2
25
> (gcd 5 5)^2
let f = undefined :: Char -> Char
let g = undefined :: Char -> Char
let z x = g (f x)    --> OK
let z x = g $ f x    --> OK
let z x = g . f x    --> NG
let z x = (g . f) x  --> OK
let z   = g . f      --> OK

Type Classes

Type Familly

Injectivity

Monad

Articles

MonadBaseControl

Language extentions

DataKind, PolyKinds

GHC

GHC-mod

Cabal

How to configure for testing

TypeCheck

Language

Servant-must-read

articles

Useful QA

migration guide

How to do ..

Haskell Quote Unquote

  • Type
    • A Type is a kind of label that every expression has.
    • A Type is an invariant condition.
    • :: is pronounced "has type"
  • Kind
    • a kind is a type of types
  • Boxed And UnBoxed
    • Boxed means that values of that type are represented by a pointer to a heap object.
    • An unboxed type, however, is represented by the value itself, no pointers or heap allocation are involved.
  • Covariant and Contravariant
    • Intuitively, a covariant type is produced, and a contravariant type is consumed.
    • If a function type a -> b appears in a covariant position, then a is in a contravariant position and b is in a covariant position.
    • If a function type a -> b appears in a contravariant position, then a is in a covariant position and b is in a contravariant position.
  • Ad hoc Parametricity
    • The purpose of " => x" is to constrain the set of possible types that the x type variable can take.
  • Type classes
    • Type classes group different types with a common interface.
    • you can think of a type class as a way to group sets of types that support the same operations.
    • Typeclasses are Haskell’s version of interfaces (in languages like Golang or Java).
  • data
    • is [d]efined [a] [t]ype [a]nd (values)
      • Note that you can defined a type without values.

About

must-read articles, papers, QAs and so on.


Languages

Language:Haskell 100.0%