Skip to content

Instantly share code, notes, and snippets.

Daniel Díaz Carrete danidiaz

  • Softtek
  • A Coruña, Spain
Block or report user

Report or block danidiaz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View _Nix.md

Nix

Nix discourse

Is there much difference between using nix-shell and docker for local development?

You need to see a Docker image as a snapshot of a machine. It will stay like it is and thus anything you do with it will keep working. However, making changes to such an image is where nondeterminism seeps in. Docker images are built using shell commands, usually it contains commands like apt-get update, apt-get install ... or wget .... These fetch information from outside sources, but because the outside sources change over time will result in different files being fetched at different times. In addition, there are no checks that the files that are being fetched are actually the ones you intended to download for your Docker image. So, Docker images will stay the same, but building the Docker image will result in a different result

View Rocs.hs
-- cabal v2-repl -b "transformers" -b "red-black-record" -b "sop-core" -b "managed" -b "profunctors" -b "aeson" -b "text"
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
@danidiaz
danidiaz / Ctors.hs
Last active Mar 2, 2019
adding and pruning ctors
View Ctors.hs
{-# LANGUAGE DataKinds, TypeApplications #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Main where
import Data.RBR (FromList,Insert,Delete,Variant,I,injectSubset,widen,injectI,winnowI,prettyShowVariantI)
import GHC.TypeLits
-- would defining these as nullary type families improve things?
type Phase01 = FromList '[ '("ctor1",Int), '("ctor2",Bool), '("ctor3",Char) ]
@danidiaz
danidiaz / cpure_NP.hs
Last active Jan 19, 2019
cpure_NP example
View cpure_NP.hs
{-# LANGUAGE DataKinds, TypeApplications #-}
-- http://hackage.haskell.org/package/sop-core
module Main where
import Data.SOP
import Data.SOP.NP (cpure_NP,cliftA_NP,collapse_NP)
import Data.Default
import Data.Proxy
-- NP is an n-ary product indexed by a type-level list. Each value is wrapped in an identity functor I.
@danidiaz
danidiaz / AKindClass.hs
Created Jan 18, 2019
kind class example
View AKindClass.hs
{-# LANGUAGE RankNTypes, DataKinds, TypeInType, PolyKinds, FlexibleInstances #-}
import Data.Proxy
import GHC.TypeLits
class Foo k
class Foo k => Bar (a :: k) where
baz :: Proxy a -> String
instance Foo k => Bar (a :: k) where
baz _ = "baz"
@danidiaz
danidiaz / WrappedFields.hs
Last active Dec 28, 2018
wrap all the fields of a record in a functor, and still allow indexing by field name
View WrappedFields.hs
{-# LANGUAGE DataKinds,
TypeFamilies,
FlexibleInstances,
UndecidableInstances,
ScopedTypeVariables,
TypeApplications,
TypeOperators,
MultiParamTypeClasses,
FunctionalDependencies,
AllowAmbiguousTypes,
@danidiaz
danidiaz / TypeLevelSymbolSet.hs
Last active Dec 26, 2018
A type-level symbol set.
View TypeLevelSymbolSet.hs
{-# LANGUAGE DataKinds,
PolyKinds,
TypeFamilies,
UndecidableInstances,
FlexibleContexts,
ScopedTypeVariables,
TypeApplications,
TypeOperators,
ExistentialQuantification,
DeriveFunctor,
View FieldsPresentOrNot.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
View _Architecture.md

Vertical decomposition. Creating cohesive services

One of the biggest misconceptions about services is that a service is an independent deployable unit, i.e., service equals process. With this view, we are defining services according to how components are physically deployed. In our example, since it’s clear that the backend admin runs in its own process/container, we consider it to be a service.

But this definition of a service is wrong. Rather you need to define your services in terms of business capabilities. The deployment aspect of the system doesn’t have to be correlated to how the system has been divided into logical services. For example, a single service might run in different components/processes, and a single component might contain parts of multiple services. Once you start thinking of services in terms of business capabilities rather than deployment units, a whole world of options open.

What are the Admin UI

View AnotherStreamingExample.hs
import Data.Foldable (toList)
import Streaming
import qualified Streaming.Prelude as S
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
main :: IO ()
main =
withFile "/tmp/source.txt" ReadMode $ \hSource ->
withFile "/tmp/target.txt" WriteMode $ \hTarget ->
You can’t perform that action at this time.