What I want is to "compose" functions taking some argument and
returning an Alt
value, like a -> m b
where Alt b
. The
resulting value should be a function from a -> m b
. The
implementation below does that, but I was wondering if there's
a better way? I'm thinking that maybe I could create a newtype
wrapper around these functions, and an Alt
instance for that
type, but I haven't gotten that to work, and I'm not sure it's
a good approach.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual IEnumerable<Commit> GetFromTo(DateTime start, DateTime end) | |
{ | |
this.ThrowWhenDisposed(); | |
Logger.Debug(Resources.GettingAllCommitsFromToTime, start, end); | |
var selectedCommitIds = this.stamps.Where(x => x.Value >= start && x.Value < end).Select(x => x.Key); | |
var firstCommitId = selectedCommitIds.FirstOrDefault(); | |
var lastCommitId = selectedCommitIds.LastOrDefault(); | |
if (lastCommitId == Guid.Empty && lastCommitId == Guid.Empty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gitlab 5.2.0 create user | |
# rake create_user["john@doe.com","johndoe","John Doe"] RAILS_ENV=production | |
desc "Create new user" | |
task :create_user, [:email, :username, :name] => :environment do |t, args| | |
puts "creating user '" + args.username + "' ('" + args.name + "') with email '" + args.email + "'" | |
@user = User.new({ email: args.email, name: args.name, username: args.username, force_random_password: true, projects_limit: 10 }, as: :admin) | |
if @user.save | |
puts "success" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
) | |
func main() { | |
syslog, err := os.Open("/var/log/system.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pkg main) | |
(import fmt) | |
;; if expressions | |
(: fib (int -> int)) | |
(def (fib n) | |
(if (== n 1) | |
0 | |
(if (== n 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------// | |
// SEMIRING // | |
//----------// | |
// Types that support addition and multiplication. | |
protocol Semiring(a) { | |
add : a -> a -> a | |
zero : a | |
mul : a -> a -> a | |
one : a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A data type wrapping a non-empty string | |
data Name : Type where | |
MkName : (s : String) -> (not (s == "") = True) -> Name | |
-- Some function that expects a valid Name | |
test : Name -> String | |
test (MkName s _) = s | |
-- Usage of that function. Do I need Refl here? Any better way of doing this? | |
foo : String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TypeSynonymsProblem where | |
import Prelude | |
import Control.Monad.Eff (Eff) | |
import Data.Either (Either) | |
import Data.Tuple (Tuple(Tuple)) | |
type Foo e a a' b b' = Eff e (Tuple a b) -> Eff e (Tuple a' b') | |
type Bar e a a' b b' = Eff e (Either a b) -> Eff e (Either a' b') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SafeWeb where | |
import Prelude | |
import Data.Array (filter) | |
import Data.Leibniz (type (~)) | |
import Data.String (Pattern(Pattern), split, joinWith) | |
type Path = Array String | |
pathToHtml :: Path -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No type class instance was found for | |
Control.Monad.Monad m0 | |
while checking that expression { path: [ "contact" | |
] | |
, GET: handler (\conn -> | |
... | |
) |