Skip to content

Instantly share code, notes, and snippets.

@naoto-ogawa
naoto-ogawa / power_of_dots.md
Last active April 14, 2018 06:35
Power of Dots

-- one dot (.)


ghci

> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
> :t .
@naoto-ogawa
naoto-ogawa / polyparse_example.hs
Last active April 10, 2020 09:45
Polyparse example
> import Text.Parse
>
-- type check
> :t word
word :: TextParser String
>
> :t runParser
runParser :: Parser t a -> [t] -> (Either String a, [t])
>
-- word
@naoto-ogawa
naoto-ogawa / IORef_and_let.md
Last active March 25, 2018 08:34
IORef and let
#
# cnt <- newIORef 1
# :t cnt
cnt :: IORef Integer
# readIORef cnt
1
# writeIORef cnt 99
# readIORef cnt
99
@naoto-ogawa
naoto-ogawa / an_example_of_including_template_in_EDE.md
Created March 24, 2018 02:50
An example of including template in EDE
  • structure
$ tree
.
└── view
    ├── base.html
    └── main.content.html
@naoto-ogawa
naoto-ogawa / custom_function_example_of?EDE.hs
Last active March 21, 2018 08:01
Custom function Example of EDE
:set -XOverloadedStrings
-- EDEをつかうため
import Text.EDE
-- カスタムの関数を作るため
import Text.EDE.Filters
-- parseがかぶるのでObjectだけインポート
import Data.Aeson.Types (Object)
-- カスタムの関数を定義を格納するマップ
import qualified Data.HashMap.Strict as Map
@naoto-ogawa
naoto-ogawa / emoji_btw_MySQL_and_Haskell.hs
Created February 22, 2018 11:09
Hemoji between MySQL and Haskell
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Example.Example18 where
import Control.Exception.Safe (SomeException, catch)
-- my library
@naoto-ogawa
naoto-ogawa / mysql_geojson_sample3.hs
Created February 21, 2018 06:09
GeoJSON communication between MySQL and Haskell
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Example.Example16 where
import Control.Exception.Safe (SomeException, catch)
-- my library
@naoto-ogawa
naoto-ogawa / mysql_gis_sample2.hs
Created February 20, 2018 11:58
Geometry Type Sample on MySQL
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies#-}
module Example.Example15 where
import Control.Exception.Safe (SomeException, catch)
-- my library
@naoto-ogawa
naoto-ogawa / mysql_gis_sample_point.hs
Created February 18, 2018 10:54
A point geometry sample on MySQL
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
module Example.Example15 where
import Control.Exception.Safe (SomeException, catch)
-- my library
import DataBase.MySQLX.NodeSession
@naoto-ogawa
naoto-ogawa / haskell_escape.hs
Created January 27, 2018 04:51
Haskell Escape
>> "a"
"a"
>> "\a"
"\a"
>> "\\a"
"\\a"
>> "\\\a"
"\\\a"
>> P.length ("a"::String)
1