Skip to content

Instantly share code, notes, and snippets.

@nushio3
nushio3 / gist:4b6ac221d46bb52a101c
Last active August 29, 2015 14:22
uom-plugin lesson
{-# OPTIONS_GHC -fplugin Data.UnitsOfMeasure.Plugin #-}
{-# LANGUAGE DataKinds, QuasiQuotes, TypeOperators #-}
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
import Data.UnitsOfMeasure
main :: IO ()
main = print ([u| 3 m |] :: Quantity Int [u| m |])
@nushio3
nushio3 / file0.txt
Created May 23, 2015 08:32
Git for Windowsでコンフリクト解決するときの手順 ref: http://qiita.com/nushio/items/601d89a8ce5844384f15
<<<<<<<<<<<< HEAD
ローカルの変更内容
============
リモートの変更内容
>>>>>>>>>>>> リモートブランチの名前
@nushio3
nushio3 / Git for Windowsでコンフリクト解決するときの手順
Created May 23, 2015 07:32 — forked from wizard-paso/コンフリクト
Git for Windowsでコンフリクト解決するときの手順
OPEN SHELLを選択
git statusを入力、エンター
both modified: ファイル名
と、コンフリクトを起こしているファイル名が表示されるので、
エディタ(メモ帳は改行が反映されてないので出来ればそれ以外、Sublime、Terapadなど)で開く
<<<<<<<<<<<<と
@nushio3
nushio3 / Pangram
Last active August 29, 2015 14:02
A pangram solver: an example for set-cover package by Henning. http://hackage.haskell.org/package/set-cover
{- |
Choose a set of words so that each alphabet is contained exactly once.
<http://en.wikipedia.org/wiki/Pangram>
This example illustrates the mose
-}
module Main where
@nushio3
nushio3 / gist:11314818
Created April 26, 2014 08:26
An example error message with -dsuppress-module-prefixes
src/Model/Disk.hs:132:16:
Couldn't match type ‘Mass’ with ‘Length’
Expected type: Getting Length s Length
Actual type: (Mass -> Const Length Mass) -> s -> Const Length s
In the first argument of ‘env’, namely ‘centralStarMass’
In the expression: env centralStarMass :: Mass
src/Model/Disk.hs:137:19:
Couldn't match type ‘Time’ with ‘Length’
Expected type: (Velocity -> f Velocity)
@nushio3
nushio3 / gist:6149755
Created August 4, 2013 08:50
threadscope test
import Control.Parallel.Strategies
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
main = do
let (rx, ry) = runEval $ do
x <- rpar $ fib 38 `seq` (undefined :: Integer)
import Control.Parallel.Strategies
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
main = print . snd . runEval $ do
x <- rpar $ (undefined :: Integer) -- (fib 100)
y <- rpar (fib 100)
@nushio3
nushio3 / arityOf.hs
Last active December 19, 2015 00:09
import Data.Typeable
import Test.Hspec
arityOf :: Typeable a => a -> Int
arityOf x = go $ typeOf x
where
go tr
| isFun $ typeRepTyCon tr = 1 + go (last $ snd $ splitTyConApp tr)
| otherwise = 0
gnuplot :: [String] -> IO ()
gnuplot cmds = do
writeFile "tmp" $ unlines cmds
system "gnuplot tmp"
return ()
main = do
gnuplot [ gnuplotSetTerm
main :: IO ()
main = top 10
top :: Int -> IO ()
top mp = do
putStrLn $ "あなたのMPは:" ++ show mp
putStrLn "どこへ行く?"
choice [ ("宿屋" , inn)
, ("野外" , outdoor mp) ]