Skip to content

Instantly share code, notes, and snippets.

View hhefesto's full-sized avatar

Daniel Herrera Rendón hhefesto

View GitHub Profile
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Handler.Support where
import Import hiding ((==.))
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Handler.Support where
import Import hiding ((==.))
@hhefesto
hhefesto / magic.hs
Last active October 18, 2018 18:51
From [a] to just a inside another monad
-- This compiles fine
getAccountInfoR :: CustomerId -> Handler Html
getAccountInfoR customerId = do
customer_info_list <- runDB $
E.select $
E.from $ \c -> do
E.where_ (c ^. CustomerId ==. E.val customerId)
return c
defaultLayout $ do
setTitle "Your Licenses"
module Handler.PostNew where
import Import
getPostNewR :: Handler Html
getPostNewR = do
defaultLayout $ do
$(widgetFile "posts/new")
@hhefesto
hhefesto / internet_example.hs
Created February 3, 2016 19:49
I am working with Persist data constructors, and I would like to be able to derive generic (on the second file) just like it is done on the first file
-----------------------------------------------------------------------------------------------------
-- from http://seanhess.github.io/2015/08/19/practical-haskell-json-api.html
-----------------------------------------------------------------------------------------------------
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Data.Monoid ((<>))
import Data.Aeson (FromJSON, ToJSON)
@hhefesto
hhefesto / Model.hs
Created January 5, 2016 01:25
using yesod's persistent.
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
@hhefesto
hhefesto / gist:878ec492aa6296001233
Created October 15, 2015 06:07
ghc compile error
➜ ghc git:(ghc-stable) ✗ make
===--- building phase 0
make -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
make[1]: Nothing to be done for 'phase_0_builds'.
===--- building phase 1
make -r --no-print-directory -f ghc.mk phase=1 phase_1_builds
"/usr/bin/ghc" -hisuf hi -osuf o -hcsuf hc -static -H32m -O -package-db libraries/bootstrapping.conf -hide-all-packages -i -ighc/. -ighc/st
age1/build -ighc/stage1/build/autogen -Ighc/stage1/build -Ighc/stage1/build/autogen -optP-include -optPghc/stage1/build/autogen/cabal_macro
s.h -package array-0.5.0.0 -package base-4.7.0.2 -package bytestring-0.10.4.0 -package directory-1.2.1.0 -package filepath-1.3.0.2 -package ghc
-7.11 -package process-1.2.0.0 -package unix-2.7.0.1 -Wall -XHaskell2010 -no-user-package-db -rtsopts -odir ghc/stage1/build -hidir ghc/
@hhefesto
hhefesto / from zsh terminal
Last active October 15, 2015 05:18
This is what i did to get the compilation error.
sudo dnf install glibc-devel ncurses-devel gmp-devel autoconf automake libtool gcc make perl python ghc happy alex git -y
sudo dnf install docbook-utils docbook-utils-pdf docbook-style-xsl -y
sudo dnf install strace patch -y
git clone --recursive git://git.haskell.org/ghc.git
cd ghc
git checkout ghc-7.10.2-release
git checkout -b ghc-stable
./boot
./configure --prefix=$HOME
@hhefesto
hhefesto / from zsh terminal
Last active October 15, 2015 05:19
ghc compilation error
➜ ghc git:(ghc-stable) ✗ make
===--- building phase 0
make -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
libraries/bin-package-db/ghc.mk:3: libraries/bin-package-db/dist-boot/package-data.mk: No such file or directory
"/usr/bin/ghc" -H32m -O \
-optc-fno-stack-protector \
\
--make utils/ghc-cabal/Main.hs -o utils/ghc-cabal/dist/build/tmp/ghc-cabal \
-no-user-package-db \
-Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
➜ aleff ghc-pkg list blaze-builder
/usr/lib64/ghc-7.8.4/package.conf.d
/home/hefesto/.ghc/x86_64-linux-7.8.4/package.conf.d
blaze-builder-0.3.3.4